Skip to content

Commit 83114df

Browse files
Yuuoniyaxboe
authored andcommitted
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: a2247f1 ("block: Add independent access ranges support") Signed-off-by: Miaoqian Lin <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent dd81e1c commit 83114df

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/blk-ia-ranges.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ int disk_register_independent_access_ranges(struct gendisk *disk,
144144
&q->kobj, "%s", "independent_access_ranges");
145145
if (ret) {
146146
q->ia_ranges = NULL;
147-
kfree(iars);
147+
kobject_put(&iars->kobj);
148148
return ret;
149149
}
150150

0 commit comments

Comments
 (0)