From: Jesper Juhl <jesper.juhl@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Mike Phillips <mikep@linuxtr.net>,
netdev@vger.kernel.org, linux-tr@linuxtr.net,
davem@davemloft.net, Jesper Juhl <jesper.juhl@gmail.com>
Subject: [PATCH 6/6][RESEND] Avoid possible NULL pointer deref in 3c359 driver
Date: Mon, 13 Aug 2007 00:22:53 +0200 [thread overview]
Message-ID: <200708130022.53998.jesper.juhl@gmail.com> (raw)
In-Reply-To: <200708130016.11281.jesper.juhl@gmail.com>
(Resending old patch originally submitted at 1/7-2007 02:19, 04-Aug-2007 20:31)
In xl_freemem(), if dev_if is NULL, the line
struct xl_private *xl_priv =(struct xl_private *)dev->priv;
will cause a NULL pointer dereference. However, if we move
that assignment below the 'if' statement that tests for a NULL
'dev', then that NULL deref can never happen.
It never hurts to be safe :-)
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index e22a3f5..671f4da 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -1044,15 +1044,17 @@ static void xl_freemem(struct net_device *dev)
static irqreturn_t xl_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *)dev_id;
- struct xl_private *xl_priv =(struct xl_private *)dev->priv;
- u8 __iomem * xl_mmio = xl_priv->xl_mmio ;
- u16 intstatus, macstatus ;
+ struct xl_private *xl_priv;
+ u8 __iomem * xl_mmio;
+ u16 intstatus, macstatus;
if (!dev) {
- printk(KERN_WARNING "Device structure dead, aaahhhh !\n") ;
+ printk(KERN_WARNING "3c359: Device structure dead, aaahhhh!\n");
return IRQ_NONE;
}
+ xl_priv = (struct xl_private *)dev->priv;
+ xl_mmio = xl_priv->xl_mmio;
intstatus = readw(xl_mmio + MMIO_INTSTATUS) ;
if (!(intstatus & 1)) /* We didn't generate the interrupt */
prev parent reply other threads:[~2007-08-12 22:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200708130016.11281.jesper.juhl@gmail.com>
2007-08-12 22:19 ` [PATCH 3/6][RESEND] Reduce size of the xterm-linux.xpm image by 12 bytes Jesper Juhl
2007-08-12 22:21 ` [PATCH 4/6][RESEND] Emulex FC HBA driver: fix overflow of statically allocated array Jesper Juhl
2007-08-13 10:56 ` James Smart
2007-08-13 11:15 ` Jesper Juhl
2007-08-13 13:10 ` James Smart
2007-08-13 15:01 ` Jesper Juhl
2007-08-12 22:21 ` [PATCH 5/6][RESEND] fix tiny spelling error in comment in cfi_cmdset_0001.c Jesper Juhl
2007-08-12 22:22 ` Jesper Juhl [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200708130022.53998.jesper.juhl@gmail.com \
--to=jesper.juhl@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tr@linuxtr.net \
--cc=mikep@linuxtr.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.