]> git.baikalelectronics.ru Git - kernel.git/commit
PCI: Fix pci_create_slot() reference count leak
authorQiushi Wu <wu000273@umn.edu>
Thu, 28 May 2020 02:13:22 +0000 (21:13 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 10 Jul 2020 20:48:22 +0000 (15:48 -0500)
commitec99ec7e65ac217dde380c497fa9e09bac38cd9d
treeb02762f2e59fa78becb79ffa0173ffef8c0b4931
parent74a27a5f5a99e6b5adfd790053b6cccac3270c76
PCI: Fix pci_create_slot() reference count leak

kobject_init_and_add() takes a reference even when it fails.  If it returns
an error, kobject_put() must be called to clean up the memory associated
with the object.

When kobject_init_and_add() fails, call kobject_put() instead of kfree().

d2d2773037cf ("net-sysfs: Fix reference count leak in
rx|netdev_queue_add_kobject") fixed a similar problem.

Link: https://lore.kernel.org/r/20200528021322.1984-1-wu000273@umn.edu
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/slot.c