Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/20200528201353.14849-1-wu000273@umn.edu
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Qiushi Wu and committed by
Martin K. Petersen
0267ffce 8c4e0f21

+1 -1
+1 -1
drivers/scsi/iscsi_boot_sysfs.c
··· 352 352 boot_kobj->kobj.kset = boot_kset->kset; 353 353 if (kobject_init_and_add(&boot_kobj->kobj, &iscsi_boot_ktype, 354 354 NULL, name, index)) { 355 - kfree(boot_kobj); 355 + kobject_put(&boot_kobj->kobj); 356 356 return NULL; 357 357 } 358 358 boot_kobj->data = data;