]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
mtip32xx: fix use-after-free on service thread failure
authorYuho Choi <dbgh9129@gmail.com>
Mon, 25 May 2026 16:25:31 +0000 (12:25 -0400)
committerJens Axboe <axboe@kernel.dk>
Tue, 26 May 2026 17:01:55 +0000 (11:01 -0600)
commit7817bdf8ee049496fa93f68cc257903f079c0180
tree2dc33ab794c07e25dab2387425b2634ec91ccc52
parenta148d0a5af1ab60253994047403f9eb41ef709a4
mtip32xx: fix use-after-free on service thread failure

If service thread creation fails after device_add_disk() succeeds,
mtip_block_initialize() calls del_gendisk() and then falls through to
put_disk(). Since mtip32xx uses .free_disk to free struct driver_data,
put_disk() can release dd on the added-disk path.

The same unwind then continues to use dd for blk_mq_free_tag_set() and
mtip_hw_exit(), and mtip_pci_probe() can later free dd again. This can
cause a use-after-free and double free.

Track whether the disk was added in the current initialization call.
For the post-add service-thread failure path, remove the disk, release
the local hardware resources, and return without dropping the final disk
reference. The probe error path can then finish its cleanup and call
put_disk() after it is done using dd. Keep the pre-add path using
put_disk() before blk_mq_free_tag_set(), and clear dd->disk so the outer
probe cleanup frees dd directly.

Fixes: e8b58ef09e84 ("mtip32xx: fix device removal")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
Link: https://patch.msgid.link/20260525162531.1406677-1-dbgh9129@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/mtip32xx/mtip32xx.c