Skip to content

Commit e8c4a76

Browse files
committed
Merge branch 'pci/hotplug'
- Fix pci_create_slot() reference count leak in failure path (Qiushi Wu) - Make rpadlpar functions static (Wei Yongjun) * pci/hotplug: PCI: rpadlpar: Make functions static PCI: Fix pci_create_slot() reference count leak
2 parents b0735e8 + 2e4770a commit e8c4a76

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

drivers/pci/hotplug/rpadlpar_core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static int dlpar_remove_vio_slot(char *drc_name, struct device_node *dn)
352352
* -ENODEV Not a valid drc_name
353353
* -EIO Internal PCI Error
354354
*/
355-
int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn)
355+
static int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn)
356356
{
357357
struct pci_bus *bus;
358358
struct slot *slot;
@@ -458,7 +458,7 @@ static inline int is_dlpar_capable(void)
458458
return (int) (rc != RTAS_UNKNOWN_SERVICE);
459459
}
460460

461-
int __init rpadlpar_io_init(void)
461+
static int __init rpadlpar_io_init(void)
462462
{
463463

464464
if (!is_dlpar_capable()) {
@@ -470,7 +470,7 @@ int __init rpadlpar_io_init(void)
470470
return dlpar_sysfs_init();
471471
}
472472

473-
void rpadlpar_io_exit(void)
473+
static void __exit rpadlpar_io_exit(void)
474474
{
475475
dlpar_sysfs_exit();
476476
}

drivers/pci/slot.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,16 @@ struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
268268
slot_name = make_slot_name(name);
269269
if (!slot_name) {
270270
err = -ENOMEM;
271+
kfree(slot);
271272
goto err;
272273
}
273274

274275
err = kobject_init_and_add(&slot->kobj, &pci_slot_ktype, NULL,
275276
"%s", slot_name);
276-
if (err)
277+
if (err) {
278+
kobject_put(&slot->kobj);
277279
goto err;
280+
}
278281

279282
INIT_LIST_HEAD(&slot->list);
280283
list_add(&slot->list, &parent->slots);
@@ -293,7 +296,6 @@ struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
293296
mutex_unlock(&pci_slot_mutex);
294297
return slot;
295298
err:
296-
kfree(slot);
297299
slot = ERR_PTR(err);
298300
goto out;
299301
}

0 commit comments

Comments
 (0)