Commit ac2044c0 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Li Nan
Browse files

block: fix error unwinding in device_add_disk

mainline inclusion
from mainline-v5.17-rc1
commit 99d8690a
category: bugfix
bugzilla: 188733

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=99d8690aae4b2f0d1d90075de355ac087f820a66



----------------------------------------

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: default avatarsyzbot <syzbot+28a66a9fbc621c939000@syzkaller.appspotmail.com>
Tested-by: default avatarsyzbot <syzbot+28a66a9fbc621c939000@syzkaller.appspotmail.com>
Fixes: 83cbce95 ("block: add error handling for device_add_disk / add_disk")
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20211221161851.788424-1-hch@lst.de


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
conflict:
  block/genhd.c
Signed-off-by: default avatarZhong Jinghua <zhongjinghua@huawei.com>
Signed-off-by: default avatarLi Nan <linan122@huawei.com>
parent ed697adf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment