Skip to content

Commit 69a1580

Browse files
Wenwen Wanggregkh
authored andcommitted
gdrom: fix a memory leak bug
[ Upstream commit 093c482 ] In probe_gdrom(), the buffer pointed by 'gd.cd_info' is allocated through kzalloc() and is used to hold the information of the gdrom device. To register and unregister the device, the pointer 'gd.cd_info' is passed to the functions register_cdrom() and unregister_cdrom(), respectively. However, this buffer is not freed after it is used, which can cause a memory leak bug. This patch simply frees the buffer 'gd.cd_info' in exit_gdrom() to fix the above issue. Signed-off-by: Wenwen Wang <[email protected]> Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent d5c411b commit 69a1580

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/cdrom/gdrom.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ static void __exit exit_gdrom(void)
882882
platform_device_unregister(pd);
883883
platform_driver_unregister(&gdrom_driver);
884884
kfree(gd.toc);
885+
kfree(gd.cd_info);
885886
}
886887

887888
module_init(init_gdrom);

0 commit comments

Comments
 (0)