linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pata_ali: check the pci_get_device failure
@ 2019-07-25  1:25 ` Navid Emamdoost
  2019-07-26 10:32   ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 2+ messages in thread
From: Navid Emamdoost @ 2019-07-25  1:25 UTC (permalink / raw)
  Cc: emamd001, kjlu, smccaman, secalert, Navid Emamdoost,
	Bartlomiej Zolnierkiewicz, Jens Axboe, linux-ide, linux-kernel

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 <navid.emamdoost@gmail.com>
---
 drivers/ata/pata_ali.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 0b122f903b8a..47d9bec1f2e2 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -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)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] pata_ali: check the pci_get_device failure
  2019-07-25  1:25 ` [PATCH] pata_ali: check the pci_get_device failure Navid Emamdoost
@ 2019-07-26 10:32   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 2+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2019-07-26 10:32 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: emamd001, kjlu, smccaman, secalert, Jens Axboe, linux-ide, linux-kernel


Hi,

On 7/25/19 3:25 AM, Navid Emamdoost wrote:
> pci_get_device may 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.

> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/ata/pata_ali.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
> index 0b122f903b8a..47d9bec1f2e2 100644
> --- a/drivers/ata/pata_ali.c
> +++ b/drivers/ata/pata_ali.c
> @@ -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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-26 10:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20190725012523epcas1p4b3ff8ee4cf2ceba3e6fa0ae0b568418f@epcas1p4.samsung.com>
2019-07-25  1:25 ` [PATCH] pata_ali: check the pci_get_device failure Navid Emamdoost
2019-07-26 10:32   ` Bartlomiej Zolnierkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).