Patchwork Fix possible null pointer dereference in ariadne.c

login
register
mail settings
Submitter Huzaifa Sidhpurwala
Date March 1, 2011, 11:33 a.m.
Message ID <1298979207-11237-1-git-send-email-huzaifas@redhat.com>
Download mbox | patch
Permalink /patch/84926/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Huzaifa Sidhpurwala - March 1, 2011, 11:33 a.m.
From: Huzaifa Sidhpurwala <huzaifas@redhat.com>

Make sure dev exists before referencing it

Signed-off-by: Huzaifa Sidhpurwala <huzaifas@redhat.com>
---
 drivers/net/ariadne.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
David Miller - March 1, 2011, 7:53 p.m.
From: huzaifas@redhat.com
Date: Tue,  1 Mar 2011 17:03:27 +0530

> +    *lance = (struct Am79C960*)dev->base_addr;

If you had actually compiled this, the compiler would have given
you a warning shoing that the leading "*" in "*lance" is not
appropriate for this assignment.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Huzaifa Sidhpurwala - March 2, 2011, 4:47 a.m.
On 03/02/2011 01:23 AM, David Miller wrote:
> From: huzaifas@redhat.com
> Date: Tue,  1 Mar 2011 17:03:27 +0530
> 
>> +    *lance = (struct Am79C960*)dev->base_addr;
> 
> If you had actually compiled this, the compiler would have given
> you a warning shoing that the leading "*" in "*lance" is not
> appropriate for this assignment.
i did build, but looks like something happened after that :(
Sorry about the mess-up , will repost the patch.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/ariadne.c b/drivers/net/ariadne.c
index 39214e5..fc3c762 100644
--- a/drivers/net/ariadne.c
+++ b/drivers/net/ariadne.c
@@ -420,7 +420,7 @@  static inline void ariadne_reset(struct net_device *dev)
 static irqreturn_t ariadne_interrupt(int irq, void *data)
 {
     struct net_device *dev = (struct net_device *)data;
-    volatile struct Am79C960 *lance = (struct Am79C960*)dev->base_addr;
+    volatile struct Am79C960 *lance;
     struct ariadne_private *priv;
     int csr0, boguscnt;
     int handled = 0;
@@ -430,6 +430,7 @@  static irqreturn_t ariadne_interrupt(int irq, void *data)
 	return IRQ_NONE;
     }
 
+    *lance = (struct Am79C960*)dev->base_addr;
     lance->RAP = CSR0;			/* PCnet-ISA Controller Status */
 
     if (!(lance->RDP & INTR))		/* Check if any interrupt has been */