]> www.infradead.org Git - users/hch/block.git/commit
block: fix error unwinding in device_add_disk add_disk-fix
authorChristoph Hellwig <hch@lst.de>
Tue, 21 Dec 2021 10:03:39 +0000 (11:03 +0100)
committerChristoph Hellwig <hch@lst.de>
Tue, 21 Dec 2021 14:36:08 +0000 (15:36 +0100)
commite9b4e2a6c1c6d507ce99179209380db95b0ee546
tree8f1eac48c1daed96149e33028713e6c08edd9cac
parent7925bb75e8effa5de85b1cf8425cd5c21f212b1d
block: fix error unwinding in device_add_disk

One device_add is called disk->ev will be freed by disk_release, so we
should free it twice.  Fix this by allocating disk->ev after device_add
so that the extra local unwinding can be removed entirely.

Based on an earlier patch from Tetsuo Handa.

Reported-by: syzbot <syzbot+28a66a9fbc621c939000@syzkaller.appspotmail.com>
Fixes: 83cbce9574462c6b ("block: add error handling for device_add_disk / add_disk")
Signed-off-by: Christoph Hellwig <hch@lst.de>
block/genhd.c