gdrom: fix a memory leak bug
authorWenwen Wang <wang6495@umn.edu>
Thu, 27 Dec 2018 02:15:13 +0000 (20:15 -0600)
committerJens Axboe <axboe@kernel.dk>
Sat, 29 Dec 2018 15:20:44 +0000 (08:20 -0700)
commit093c48213ee37c3c3ff1cf5ac1aa2a9d8bc66017
treeadfb5cabb32a5efc2060d232f577270fae3e2b48
parentd52c499b476b2f82eebecdd5fc4be8318a4e8ef7
gdrom: fix a memory leak bug

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 <wang6495@umn.edu>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/cdrom/gdrom.c