From: Colin Ian King <colin.king@canonical.com>
To: David Miller <davem@davemloft.net>
Cc: bhutchings@solarflare.com, jpr@f6fbb.org,
linux-hams@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH] yam: avoid null pointer dereference error
Date: Wed, 27 Mar 2013 18:08:10 +0000 [thread overview]
Message-ID: <5153358A.5010505@canonical.com> (raw)
In-Reply-To: <20130327.134651.702432728001011428.davem@davemloft.net>
[-- Attachment #1: Type: text/plain, Size: 643 bytes --]
On 27/03/13 17:46, David Miller wrote:
> From: Ben Hutchings <bhutchings@solarflare.com>
> Date: Wed, 27 Mar 2013 17:44:17 +0000
>
>> On Wed, 2013-03-27 at 11:19 +0000, Colin King wrote:
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> yam_open checks if dev is null, however, before that check it
>>> accesses some of the fields from dev in a proceeding printk which
>>> will cause a null pointer dereference error if dev is nul. Move
>>> the printk to after the null check.
>>
>> This function will never be called with dev == NULL.
>
> Then let's remove at least that part of the check.
>
Good point. How about the following..
[-- Attachment #2: 0001-yam-remove-redundant-null-check-on-dev.patch --]
[-- Type: text/x-diff, Size: 1133 bytes --]
From 564f111f196d9d7293e922a68ba973210d191129 Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Wed, 27 Mar 2013 13:59:05 -0400
Subject: [PATCH] yam: remove redundant null check on dev
yam_open has a redundant null check on null, it will
never be called with dev == NULL. Remove this redundant check.
This also cleans up a smatch warning:
drivers/net/hamradio/yam.c:869 yam_open() warn: variable
dereferenced before check 'dev' (see line 867)
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/hamradio/yam.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index 4cf8f10..b2d863f 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -866,7 +866,7 @@ static int yam_open(struct net_device *dev)
printk(KERN_INFO "Trying %s at iobase 0x%lx irq %u\n", dev->name, dev->base_addr, dev->irq);
- if (!dev || !yp->bitrate)
+ if (!yp->bitrate)
return -ENXIO;
if (!dev->base_addr || dev->base_addr > 0x1000 - YAM_EXTENT ||
dev->irq < 2 || dev->irq > 15) {
--
1.7.9.5
next prev parent reply other threads:[~2013-03-27 18:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-27 11:19 [PATCH] yam: avoid null pointer dereference error Colin King
2013-03-27 17:44 ` Ben Hutchings
2013-03-27 17:46 ` David Miller
2013-03-27 18:08 ` Colin Ian King [this message]
2013-03-27 18:12 ` Ben Hutchings
2013-03-27 18:14 ` David Miller
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=5153358A.5010505@canonical.com \
--to=colin.king@canonical.com \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=jpr@f6fbb.org \
--cc=linux-hams@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox