netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] via-ircc: don't return zero if via_ircc_open() failed
@ 2013-08-16 20:48 Alexey Khoroshilov
  2013-08-20 20:27 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Khoroshilov @ 2013-08-16 20:48 UTC (permalink / raw)
  To: Samuel Ortiz, David S . Miller
  Cc: Alexey Khoroshilov, netdev, linux-kernel, ldv-project

If via_ircc_open() fails, data structures of the driver left uninitialized,
but probe (via_init_one()) returns zero. That can lead to null pointer dereference
in via_remove_one(), since it does not check drvdata for NULL.

The patch implements proper error code propagation.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/net/irda/via-ircc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
index 51f2bc3..2dcc60f 100644
--- a/drivers/net/irda/via-ircc.c
+++ b/drivers/net/irda/via-ircc.c
@@ -210,8 +210,7 @@ static int via_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
 			pci_write_config_byte(pcidev,0x42,(bTmp | 0xf0));
 			pci_write_config_byte(pcidev,0x5a,0xc0);
 			WriteLPCReg(0x28, 0x70 );
-			if (via_ircc_open(pcidev, &info, 0x3076) == 0)
-				rc=0;
+			rc = via_ircc_open(pcidev, &info, 0x3076);
 		} else
 			rc = -ENODEV; //IR not turn on	 
 	} else { //Not VT1211
@@ -249,8 +248,7 @@ static int via_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
 			info.irq=FirIRQ;
 			info.dma=FirDRQ1;
 			info.dma2=FirDRQ0;
-			if (via_ircc_open(pcidev, &info, 0x3096) == 0)
-				rc=0;
+			rc = via_ircc_open(pcidev, &info, 0x3096);
 		} else
 			rc = -ENODEV; //IR not turn on !!!!!
 	}//Not VT1211
-- 
1.8.1.2

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

* Re: [PATCH] via-ircc: don't return zero if via_ircc_open() failed
  2013-08-16 20:48 [PATCH] via-ircc: don't return zero if via_ircc_open() failed Alexey Khoroshilov
@ 2013-08-20 20:27 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-08-20 20:27 UTC (permalink / raw)
  To: khoroshilov; +Cc: samuel, netdev, linux-kernel, ldv-project

From: Alexey Khoroshilov <khoroshilov@ispras.ru>
Date: Fri, 16 Aug 2013 23:48:14 +0300

> If via_ircc_open() fails, data structures of the driver left uninitialized,
> but probe (via_init_one()) returns zero. That can lead to null pointer dereference
> in via_remove_one(), since it does not check drvdata for NULL.
> 
> The patch implements proper error code propagation.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>

Applied, thanks.

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

end of thread, other threads:[~2013-08-20 20:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-16 20:48 [PATCH] via-ircc: don't return zero if via_ircc_open() failed Alexey Khoroshilov
2013-08-20 20:27 ` David Miller

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).