Skip to content

Commit 0267ffc

Browse files
QiushiWumartinkpetersen
authored andcommitted
scsi: iscsi: Fix reference count leak in iscsi_boot_create_kobj
kobject_init_and_add() takes reference even when it fails. If this function returns an error, kobject_put() must be called to properly clean up the memory associated with the object. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Lee Duncan <[email protected]> Signed-off-by: Qiushi Wu <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 8c4e0f2 commit 0267ffc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/scsi/iscsi_boot_sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ iscsi_boot_create_kobj(struct iscsi_boot_kset *boot_kset,
352352
boot_kobj->kobj.kset = boot_kset->kset;
353353
if (kobject_init_and_add(&boot_kobj->kobj, &iscsi_boot_ktype,
354354
NULL, name, index)) {
355-
kfree(boot_kobj);
355+
kobject_put(&boot_kobj->kobj);
356356
return NULL;
357357
}
358358
boot_kobj->data = data;

0 commit comments

Comments
 (0)