From: David Miller <davem@davemloft.net>
To: bcrl@kvack.org
Cc: jj@chaosbits.net, netdev@vger.kernel.org,
linux-ns83820@kvack.org, linux-kernel@vger.kernel.org,
tj@kernel.org, segooon@gmail.com, dkirjanov@kernel.org
Subject: Re: [PATCH] ns83820: Avoid bad pointer deref in ns83820_init_one().
Date: Tue, 18 Jan 2011 16:14:31 -0800 (PST) [thread overview]
Message-ID: <20110118.161431.245411919.davem@davemloft.net> (raw)
In-Reply-To: <20110118164200.GI17839@kvack.org>
From: Benjamin LaHaise <bcrl@kvack.org>
Date: Tue, 18 Jan 2011 11:42:00 -0500
> On Mon, Jan 17, 2011 at 09:24:57PM +0100, Jesper Juhl wrote:
>> In drivers/net/ns83820.c::ns83820_init_one() we dynamically allocate
>> memory via alloc_etherdev(). We then call PRIV() on the returned storage
>> which is 'return netdev_priv()'. netdev_priv() takes the pointer it is
>> passed and adds 'ALIGN(sizeof(struct net_device), NETDEV_ALIGN)' to it and
>> returns it. Then we test the resulting pointer for NULL, which it is
>> unlikely to be at this point, and later dereference it. This will go bad
>> if alloc_etherdev() actually returned NULL.
>>
>> This patch reworks the code slightly so that we test for a NULL pointer
>> (and return -ENOMEM) directly after calling alloc_etherdev().
>
> Looks good.
>
> -ben
>
> Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
Applied, thanks everyone.
prev parent reply other threads:[~2011-01-19 0:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-17 20:24 [PATCH] ns83820: Avoid bad pointer deref in ns83820_init_one() Jesper Juhl
2011-01-18 14:11 ` Denis Kirjanov
2011-01-18 16:42 ` Benjamin LaHaise
2011-01-19 0:14 ` David Miller [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=20110118.161431.245411919.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=bcrl@kvack.org \
--cc=dkirjanov@kernel.org \
--cc=jj@chaosbits.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-ns83820@kvack.org \
--cc=netdev@vger.kernel.org \
--cc=segooon@gmail.com \
--cc=tj@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;
as well as URLs for NNTP newsgroup(s).