mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
drivers/block/null_blk/main: Fix a double free in null_init.
[ Upstream commit 72ce11ddfa4e9e1879103581a60b7e34547eaa0a ]
In null_init, null_add_dev(dev) is called.
In null_add_dev, it calls null_free_zoned_dev(dev) to free dev->zones
via kvfree(dev->zones) in out_cleanup_zone branch and returns err.
Then null_init accept the err code and then calls null_free_dev(dev).
But in null_free_dev(dev), dev->zones is freed again by
null_free_zoned_dev().
My patch set dev->zones to NULL in null_free_zoned_dev() after
kvfree(dev->zones) is called, to avoid the double free.
Fixes: 2984c8684f ("nullb: factor disk parameters")
Signed-off-by: Lv Yunlong <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
This commit is contained in:
parent
279749d0d4
commit
59021008b3
1 changed files with 1 additions and 0 deletions
|
|
@ -73,6 +73,7 @@ int null_zone_init(struct nullb_device *dev)
|
|||
void null_zone_exit(struct nullb_device *dev)
|
||||
{
|
||||
kvfree(dev->zones);
|
||||
dev->zones = NULL;
|
||||
}
|
||||
|
||||
int null_zone_report(struct gendisk *disk, sector_t sector,
|
||||
|
|
|
|||
Loading…
Reference in a new issue