]> git.baikalelectronics.ru Git - kernel.git/commit
block: fix memory leak in disk_register_independent_access_ranges
authorMiaoqian Lin <linmq006@gmail.com>
Thu, 20 Jan 2022 10:10:25 +0000 (10:10 +0000)
committerJens Axboe <axboe@kernel.dk>
Sun, 23 Jan 2022 16:13:09 +0000 (09:13 -0700)
commitd565dec70d3bf36e04e698e9e00b8689fa645c55
tree5874ade6731fa6ce555079d29b7c1d29a41a06a3
parent4023af67116b4365c2e4de271849bd37c4db550e
block: fix memory leak in disk_register_independent_access_ranges

kobject_init_and_add() takes reference even when it fails.
According to the doc of kobject_init_and_add()

   If this function returns an error, kobject_put() must be called to
   properly clean up the memory associated with the object.

Fix this issue by adding kobject_put().
Callback function blk_ia_ranges_sysfs_release() in kobject_put()
can handle the pointer "iars" properly.

Fixes: dc74d7921761 ("block: Add independent access ranges support")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Link: https://lore.kernel.org/r/20220120101025.22411-1-linmq006@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-ia-ranges.c