All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: fix error handling for device_add_disk
@ 2021-12-16 16:00 Tetsuo Handa
  2021-12-16 16:18 ` Christoph Hellwig
  0 siblings, 1 reply; 13+ messages in thread
From: Tetsuo Handa @ 2021-12-16 16:00 UTC (permalink / raw)
  To: Jens Axboe, Christoph Hellwig, Luis Chamberlain; +Cc: linux-block

syzbot is reporting double kfree() bug in disk_release_events() [1], for
commit 9be68dd7ac0e13be ("md: add error handling support for add_disk()")
is calling blk_cleanup_disk() which will call disk_release_events() from
regular kobject_release() path when device_add_disk() from add_disk()
failed.

Since kobject_release() will be always called regardless of whether
device_add_disk() from add_disk() succeeds, we should leave
disk_release_events() to regular kobject_release() path.

Link: https://syzkaller.appspot.com/bug?extid=28a66a9fbc621c939000 [1]
Reported-by: syzbot <syzbot+28a66a9fbc621c939000@syzkaller.appspotmail.com>
Tested-by: syzbot <syzbot+28a66a9fbc621c939000@syzkaller.appspotmail.com>
Fixes: 83cbce9574462c6b ("block: add error handling for device_add_disk / add_disk")
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 block/genhd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/genhd.c b/block/genhd.c
index 30362aeacac4..47bb34ab967b 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -540,7 +540,7 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
 out_device_del:
 	device_del(ddev);
 out_disk_release_events:
-	disk_release_events(disk);
+	/* disk_release() will call disk_release_events(). */
 out_free_ext_minor:
 	if (disk->major == BLOCK_EXT_MAJOR)
 		blk_free_ext_minor(disk->first_minor);
-- 
2.32.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-12-21 21:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-16 16:00 [PATCH] block: fix error handling for device_add_disk Tetsuo Handa
2021-12-16 16:18 ` Christoph Hellwig
2021-12-16 16:19   ` Christoph Hellwig
2021-12-17 10:37     ` Tetsuo Handa
2021-12-19 20:00       ` Luis Chamberlain
2021-12-20  8:23         ` Tetsuo Handa
2021-12-20 19:16           ` Luis Chamberlain
2021-12-21 11:41             ` Tetsuo Handa
2021-12-21 21:50               ` Luis Chamberlain
2021-12-21 10:08       ` Christoph Hellwig
2021-12-21 10:15         ` Christoph Hellwig
2021-12-21 10:21           ` Tetsuo Handa
2021-12-21 13:46           ` Tetsuo Handa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.