pata_ali: check the pci_get_device failure
PATCH 1/1 pata_ali: check the pci_get_device failure
pci_get_device may fail and return NULL. This eventually will be dereferenced in __pci_register_driver. So null check is necessary.
Signed-off-by Navid Emamdoost <[email protected]>
--- drivers/ata/pata_ali.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/ata/pata_ali.c +2 -0
@@ -627,6 +627,8 @@ static int __init ali_init(void) {int ret; ali_isa_bridge =pci_get_device (PCI_VENDOR_ID_AL ,PCI_DEVICE_ID_AL_M1533 ,NULL ); +if (!ali_isa_bridge) +return -EINVAL ; ret =pci_register_driver (&ali_pci_driver);if (ret <0 )
Signature · 1 line
2.17.1
Hi,
Quoted 2 lines · Navid Emamdoost
pci_get_devicemay fail and return NULL. This eventually will be dereferenced in__pci_register_driver. So null check is necessary.
I'm sorry to say this but the patch is incorrect and should not be applied.
ALI M1533 ISA bridge presence is optional (the driver can work also with other ISA bridges) and ali_isa_bridge is always correctly checked for NULL before being dereferenced in the driver.
Quoted 10 lines
Signed-off-by Navid Emamdoost <[email protected]>--- drivers/ata/pata_ali.c | 2 ++ 1 file changed, 2 insertions(+)drivers/ata/pata_ali.c +0
-0
drivers/ata/pata_ali.c static int __init ali_init(void) · line 634
Quoted 8 lines
drivers/ata/pata_ali.c +2
-0@@ -627,6 +627,8 @@ static int __init ali_init(void) {int ret; ali_isa_bridge =pci_get_device (PCI_VENDOR_ID_AL ,PCI_DEVICE_ID_AL_M1533 ,NULL ); +if (!ali_isa_bridge) +return -EINVAL ; ret =pci_register_driver (&ali_pci_driver);if (ret <0 )
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics