]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
efi/esrt: Fix reference count leak in esre_create_sysfs_entry.
authorQiushi Wu <wu000273@umn.edu>
Thu, 28 May 2020 18:38:04 +0000 (13:38 -0500)
committerArd Biesheuvel <ardb@kernel.org>
Mon, 15 Jun 2020 12:38:56 +0000 (14:38 +0200)
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. Previous
commit "b8eb718348b8" fixed a similar problem.

Fixes: 0bb549052d33 ("efi: Add esrt support")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Link: https://lore.kernel.org/r/20200528183804.4497-1-wu000273@umn.edu
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/esrt.c

index e3d692696583461489c08e0b3c0fd4fee44f6383..d5915272141fd27b18676109809e6d56cdd86e61 100644 (file)
@@ -181,7 +181,7 @@ static int esre_create_sysfs_entry(void *esre, int entry_num)
                rc = kobject_init_and_add(&entry->kobj, &esre1_ktype, NULL,
                                          "entry%d", entry_num);
                if (rc) {
-                       kfree(entry);
+                       kobject_put(&entry->kobj);
                        return rc;
                }
        }