From: Firo Yang <firogm@gmail.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
davem@davemloft.net, kuznet@ms2.inr.ac.ru, jmorris@namei.org,
yoshfuji@linux-ipv6.org, kaber@trash.net, netdev@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] fib_trie: Fix potential null pointer dereference
Date: Sun, 07 Jun 2015 13:19:24 +0000 [thread overview]
Message-ID: <20150607131924.GA16087@firo> (raw)
In-Reply-To: <alpine.DEB.2.02.1506070835310.2108@localhost6.localdomain6>
On Sun, Jun 07, 2015 at 08:36:45AM +0200, Julia Lawall wrote:
>
>
>On Sun, 7 Jun 2015, Firo Yang wrote:
>
>> On Sat, Jun 06, 2015 at 05:05:04AM -0700, Eric Dumazet wrote:
>> >On Sat, 2015-06-06 at 19:35 +0800, Firo Yang wrote:
>> >> A smatch warning.
>> >> When kmem_cache_alloc() failed to alloc memory, a null pointer
>> >> will be returned. Redeference null pointer will generate
>> >
>> >
>> >Dereferencing a null pointer will crash.
>> >
>> >> an unnecessary oops. So, use it after check.
>> >>
>> >> Signed-off-by: Firo Yang <firogm@gmail.com>
>> >> ---
>> >> net/ipv4/fib_trie.c | 3 ++-
>> >> 1 file changed, 2 insertions(+), 1 deletion(-)
>> >>
>> >> diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
>> >> index 01bce15..34094c7 100644
>> >> --- a/net/ipv4/fib_trie.c
>> >> +++ b/net/ipv4/fib_trie.c
>> >> @@ -326,12 +326,13 @@ static inline void empty_child_dec(struct key_vector *n)
>> >> static struct key_vector *leaf_new(t_key key, struct fib_alias *fa)
>> >> {
>> >> struct tnode *kv = kmem_cache_alloc(trie_leaf_kmem, GFP_KERNEL);
>> >> - struct key_vector *l = kv->kv;
>> >> + struct key_vector *l;
>> >>
>> >> if (!kv)
>> >> return NULL;
>> >>
>> >> /* initialize key vector */
>> >> + l = kv->kv;
>> >> l->key = key;
>> >> l->pos = 0;
>> >> l->bits = 0;
>> >
>> >Fixes: dc35dbeda3e0 ("fib_trie: Add tnode struct as a container for fields not needed in key_vector")
>> >Acked-by: Eric Dumazet <edumazet@google.com>
>> >
>> >Thanks.
>>
>> Hi Eric,
>> Please discard this useless patch figured out by Alexander Duyck.
>> I will send a patch to Smatch for eliminating the negative warning.
>
>I think that many people would make the same mistake when looking at the
>code. The change doesn't seem to hurt anything?
Actually, yes. But it does imporve nothing but coding style.
I think Alexander's code style make function more compact is also a
good code style. So, just keep it original.
Firo
>
>julia
--
WARNING: multiple messages have this Message-ID (diff)
From: Firo Yang <firogm@gmail.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
davem@davemloft.net, kuznet@ms2.inr.ac.ru, jmorris@namei.org,
yoshfuji@linux-ipv6.org, kaber@trash.net, netdev@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] fib_trie: Fix potential null pointer dereference
Date: Sun, 7 Jun 2015 21:19:24 +0800 [thread overview]
Message-ID: <20150607131924.GA16087@firo> (raw)
In-Reply-To: <alpine.DEB.2.02.1506070835310.2108@localhost6.localdomain6>
On Sun, Jun 07, 2015 at 08:36:45AM +0200, Julia Lawall wrote:
>
>
>On Sun, 7 Jun 2015, Firo Yang wrote:
>
>> On Sat, Jun 06, 2015 at 05:05:04AM -0700, Eric Dumazet wrote:
>> >On Sat, 2015-06-06 at 19:35 +0800, Firo Yang wrote:
>> >> A smatch warning.
>> >> When kmem_cache_alloc() failed to alloc memory, a null pointer
>> >> will be returned. Redeference null pointer will generate
>> >
>> >
>> >Dereferencing a null pointer will crash.
>> >
>> >> an unnecessary oops. So, use it after check.
>> >>
>> >> Signed-off-by: Firo Yang <firogm@gmail.com>
>> >> ---
>> >> net/ipv4/fib_trie.c | 3 ++-
>> >> 1 file changed, 2 insertions(+), 1 deletion(-)
>> >>
>> >> diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
>> >> index 01bce15..34094c7 100644
>> >> --- a/net/ipv4/fib_trie.c
>> >> +++ b/net/ipv4/fib_trie.c
>> >> @@ -326,12 +326,13 @@ static inline void empty_child_dec(struct key_vector *n)
>> >> static struct key_vector *leaf_new(t_key key, struct fib_alias *fa)
>> >> {
>> >> struct tnode *kv = kmem_cache_alloc(trie_leaf_kmem, GFP_KERNEL);
>> >> - struct key_vector *l = kv->kv;
>> >> + struct key_vector *l;
>> >>
>> >> if (!kv)
>> >> return NULL;
>> >>
>> >> /* initialize key vector */
>> >> + l = kv->kv;
>> >> l->key = key;
>> >> l->pos = 0;
>> >> l->bits = 0;
>> >
>> >Fixes: dc35dbeda3e0 ("fib_trie: Add tnode struct as a container for fields not needed in key_vector")
>> >Acked-by: Eric Dumazet <edumazet@google.com>
>> >
>> >Thanks.
>>
>> Hi Eric,
>> Please discard this useless patch figured out by Alexander Duyck.
>> I will send a patch to Smatch for eliminating the negative warning.
>
>I think that many people would make the same mistake when looking at the
>code. The change doesn't seem to hurt anything?
Actually, yes. But it does imporve nothing but coding style.
I think Alexander's code style make function more compact is also a
good code style. So, just keep it original.
Firo
>
>julia
--
next prev parent reply other threads:[~2015-06-07 13:19 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-06 11:35 [PATCH] fib_trie: Fix potential null pointer dereference Firo Yang
2015-06-06 11:35 ` Firo Yang
2015-06-06 12:05 ` Eric Dumazet
2015-06-06 12:05 ` Eric Dumazet
2015-06-07 3:20 ` Alexander Duyck
2015-06-07 3:20 ` Alexander Duyck
[not found] ` <5573B7A2.4010607@gmail.com>
2015-06-07 4:46 ` Firo Yang
2015-06-07 4:46 ` Firo Yang
2015-06-07 6:01 ` Firo Yang
2015-06-07 6:01 ` Firo Yang
2015-06-07 6:36 ` Julia Lawall
2015-06-07 6:36 ` Julia Lawall
2015-06-07 13:19 ` Firo Yang [this message]
2015-06-07 13:19 ` Firo Yang
2015-06-07 13:23 ` Julia Lawall
2015-06-07 13:23 ` Julia Lawall
2015-06-07 13:42 ` Firo Yang
2015-06-07 13:42 ` Firo Yang
2015-06-07 16:36 ` Alexander Duyck
2015-06-07 16:36 ` Alexander Duyck
2015-06-06 13:39 ` walter harms
2015-06-06 13:39 ` walter harms
2015-06-07 4:52 ` Firo Yang
2015-06-07 4:52 ` Firo Yang
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=20150607131924.GA16087@firo \
--to=firogm@gmail.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=jmorris@namei.org \
--cc=julia.lawall@lip6.fr \
--cc=kaber@trash.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuznet@ms2.inr.ac.ru \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.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.