s390/pci: Fix missing check for zpci_create_device() error return
authorNiklas Schnelle <schnelle@linux.ibm.com>
Wed, 30 Apr 2025 13:26:18 +0000 (15:26 +0200)
committerHeiko Carstens <hca@linux.ibm.com>
Wed, 7 May 2025 11:35:05 +0000 (13:35 +0200)
The zpci_create_device() function returns an error pointer that needs to
be checked before dereferencing it as a struct zpci_dev pointer. Add the
missing check in __clp_add() where it was missed when adding the
scan_list in the fixed commit. Simply not adding the device to the scan
list results in the previous behavior.

Cc: stable@vger.kernel.org
Fixes: 0467cdde8c43 ("s390/pci: Sort PCI functions prior to creating virtual busses")
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Gerd Bayer <gbayer@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/pci/pci_clp.c

index 9a929bbcc39722b76c4f42074145c668239dca08..241f7251c8730ff0cd8228905125f752b3338731 100644 (file)
@@ -428,6 +428,8 @@ static void __clp_add(struct clp_fh_list_entry *entry, void *data)
                return;
        }
        zdev = zpci_create_device(entry->fid, entry->fh, entry->config_state);
+       if (IS_ERR(zdev))
+               return;
        list_add_tail(&zdev->entry, scan_list);
 }