From: Qiushi Wu Date: Thu, 28 May 2020 20:13:53 +0000 (-0500) Subject: scsi: iscsi: Fix reference count leak in iscsi_boot_create_kobj X-Git-Tag: v5.10.7~2312^2~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0267ffce562c8bbf9b57ebe0e38445ad04972890;p=platform%2Fkernel%2Flinux-rpi.git 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 Signed-off-by: Qiushi Wu Signed-off-by: Martin K. Petersen --- diff --git a/drivers/scsi/iscsi_boot_sysfs.c b/drivers/scsi/iscsi_boot_sysfs.c index e4857b7..a64abe3 100644 --- a/drivers/scsi/iscsi_boot_sysfs.c +++ b/drivers/scsi/iscsi_boot_sysfs.c @@ -352,7 +352,7 @@ iscsi_boot_create_kobj(struct iscsi_boot_kset *boot_kset, boot_kobj->kobj.kset = boot_kset->kset; if (kobject_init_and_add(&boot_kobj->kobj, &iscsi_boot_ktype, NULL, name, index)) { - kfree(boot_kobj); + kobject_put(&boot_kobj->kobj); return NULL; } boot_kobj->data = data;