linux-stable/drivers/pci
Jubin Zhong 39a6f4bef6 PCI: Fix pci_slot_release() NULL pointer dereference
commit 4684709bf8 upstream.

If kobject_init_and_add() fails, pci_slot_release() is called to delete
slot->list from parent->slots.  But slot->list hasn't been initialized
yet, so we dereference a NULL pointer:

  Unable to handle kernel NULL pointer dereference at virtual address
00000000
  ...
  CPU: 10 PID: 1 Comm: swapper/0 Not tainted 4.4.240 #197
  task: ffffeb398a45ef10 task.stack: ffffeb398a470000
  PC is at __list_del_entry_valid+0x5c/0xb0
  LR is at pci_slot_release+0x84/0xe4
  ...
  __list_del_entry_valid+0x5c/0xb0
  pci_slot_release+0x84/0xe4
  kobject_put+0x184/0x1c4
  pci_create_slot+0x17c/0x1b4
  __pci_hp_initialize+0x68/0xa4
  pciehp_probe+0x1a4/0x2fc
  pcie_port_probe_service+0x58/0x84
  driver_probe_device+0x320/0x470

Initialize slot->list before calling kobject_init_and_add() to avoid this.

Fixes: 8a94644b44 ("PCI: Fix pci_create_slot() reference count leak")
Link: https://lore.kernel.org/r/1606876422-117457-1-git-send-email-zhongjubin@huawei.com
Signed-off-by: Jubin Zhong <zhongjubin@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org	# v5.9+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-12-30 11:54:28 +01:00
..
controller PCI: iproc: Invalidate correct PAXB inbound windows 2020-12-30 11:53:27 +01:00
endpoint
hotplug pci-v5.10-changes 2020-10-22 12:41:00 -07:00
pcie Merge branch 'pci/misc' 2020-10-21 09:58:36 -05:00
switch
access.c
ats.c
bus.c
ecam.c
host-bridge.c
iov.c
irq.c
Kconfig pci-v5.10-changes 2020-10-22 12:41:00 -07:00
Makefile
mmap.c
msi.c
of.c
p2pdma.c pci-v5.10-changes 2020-10-22 12:41:00 -07:00
pci-acpi.c PM: ACPI: PCI: Drop acpi_pm_set_bridge_wakeup() 2020-12-30 11:54:05 +01:00
pci-bridge-emul.c
pci-bridge-emul.h
pci-driver.c pci-v5.10-changes 2020-10-22 12:41:00 -07:00
pci-label.c
pci-mid.c
pci-pf-stub.c
pci-stub.c
pci-sysfs.c Merge branch 'pci/misc' 2020-10-21 09:58:36 -05:00
pci.c PCI: Fix overflow in command-line resource alignment requests 2020-12-30 11:53:26 +01:00
pci.h
probe.c Merge branch 'remotes/lorenzo/pci/dwc' 2020-10-21 09:58:39 -05:00
proc.c
quirks.c PCI: Disable MSI for Pericom PCIe-USB adapter 2020-12-30 11:53:18 +01:00
remove.c
rom.c
search.c
setup-bus.c
setup-irq.c
setup-res.c
slot.c PCI: Fix pci_slot_release() NULL pointer dereference 2020-12-30 11:54:28 +01:00
syscall.c
vc.c
vpd.c
xen-pcifront.c dma-mapping: split <linux/dma-mapping.h> 2020-10-06 07:07:03 +02:00