linux-stable/block/partitions
Zqiang 9fbfabfda2 block: fix incorrect references to disk objects
When adding partitions to the disk, the reference count of the disk
object is increased. then alloc partition device and called
device_add(), if the device_add() return error, the reference
count of the disk object will be reduced twice, at put_device(pdev)
and put_disk(disk). this leads to the end of the object's life cycle
prematurely, and trigger following calltrace.

  __init_work+0x2d/0x50 kernel/workqueue.c:519
  synchronize_rcu_expedited+0x3af/0x650 kernel/rcu/tree_exp.h:847
  bdi_remove_from_list mm/backing-dev.c:938 [inline]
  bdi_unregister+0x17f/0x5c0 mm/backing-dev.c:946
  release_bdi+0xa1/0xc0 mm/backing-dev.c:968
  kref_put include/linux/kref.h:65 [inline]
  bdi_put+0x72/0xa0 mm/backing-dev.c:976
  bdev_free_inode+0x11e/0x220 block/bdev.c:408
  i_callback+0x3f/0x70 fs/inode.c:226
  rcu_do_batch kernel/rcu/tree.c:2508 [inline]
  rcu_core+0x76d/0x16c0 kernel/rcu/tree.c:2743
  __do_softirq+0x1d7/0x93b kernel/softirq.c:558
  invoke_softirq kernel/softirq.c:432 [inline]
  __irq_exit_rcu kernel/softirq.c:636 [inline]
  irq_exit_rcu+0xf2/0x130 kernel/softirq.c:648
  sysvec_apic_timer_interrupt+0x93/0xc0

making disk is NULL when calling put_disk().

Reported-by: Hao Sun <sunhao.th@gmail.com>
Signed-off-by: Zqiang <qiang.zhang1211@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20211018103422.2043-1-qiang.zhang1211@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-10-18 11:20:38 -06:00
..
acorn.c block: store a gendisk in struct parsed_partitions 2021-08-12 10:31:35 -06:00
aix.c block: store a gendisk in struct parsed_partitions 2021-08-12 10:31:35 -06:00
amiga.c block: store a gendisk in struct parsed_partitions 2021-08-12 10:31:35 -06:00
atari.c block: store a gendisk in struct parsed_partitions 2021-08-12 10:31:35 -06:00
atari.h block: declare all partition detection routines in check.h 2020-03-24 07:57:08 -06:00
check.h block: store a gendisk in struct parsed_partitions 2021-08-12 10:31:35 -06:00
cmdline.c block: store a gendisk in struct parsed_partitions 2021-08-12 10:31:35 -06:00
core.c block: fix incorrect references to disk objects 2021-10-18 11:20:38 -06:00
efi.c partitions/efi: Support non-standard GPT location 2021-08-24 10:09:06 -06:00
efi.h Merge branch 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2020-03-30 16:13:08 -07:00
ibm.c block: store a gendisk in struct parsed_partitions 2021-08-12 10:31:35 -06:00
karma.c block: remove block/partitions/karma.h 2020-03-24 07:57:08 -06:00
Kconfig block: remove cmdline-parser.c 2021-08-02 13:37:28 -06:00
ldm.c for-5.15/block-2021-08-30 2021-08-30 18:52:11 -07:00
ldm.h partitions: msdos: fix one-byte get_unaligned() 2021-05-17 13:30:29 +02:00
mac.c block: store a gendisk in struct parsed_partitions 2021-08-12 10:31:35 -06:00
mac.h block: declare all partition detection routines in check.h 2020-03-24 07:57:08 -06:00
Makefile block: merge partition-generic.c and check.c 2020-03-24 07:57:08 -06:00
msdos.c block: store a gendisk in struct parsed_partitions 2021-08-12 10:31:35 -06:00
osf.c block: remove block/partitions/osf.h 2020-03-24 07:57:08 -06:00
sgi.c block: store a gendisk in struct parsed_partitions 2021-08-12 10:31:35 -06:00
sun.c block: store a gendisk in struct parsed_partitions 2021-08-12 10:31:35 -06:00
sysv68.c block: declare all partition detection routines in check.h 2020-03-24 07:57:08 -06:00
ultrix.c block: declare all partition detection routines in check.h 2020-03-24 07:57:08 -06:00