Linux-ide Archive on lore.kernel.org
 help / color / 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)
  To: unlisted-recipients:; (no To-header on input)
  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	[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, back to index

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

Linux-ide Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-ide/0 linux-ide/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-ide linux-ide/ https://lore.kernel.org/linux-ide \
		linux-ide@vger.kernel.org linux-ide@archiver.kernel.org
	public-inbox-index linux-ide


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-ide


AGPL code for this site: git clone https://public-inbox.org/ public-inbox