Patchwork ipv4: fix NULL checking in devinet_ioctl()

login
register
mail settings
Submitter Xi Wang
Date Jan. 5, 2013, 9:19 p.m.
Message ID <1357420764-12381-1-git-send-email-xi.wang@gmail.com>
Download mbox | patch
Permalink /patch/209699/
State Accepted
Delegated to: David Miller
Headers show

Comments

Xi Wang - Jan. 5, 2013, 9:19 p.m.
The NULL pointer check `!ifa' should come before its first use.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
---
 net/ipv4/devinet.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Eric Dumazet - Jan. 5, 2013, 11:10 p.m.
On Sat, 2013-01-05 at 16:19 -0500, Xi Wang wrote:
> The NULL pointer check `!ifa' should come before its first use.
> 
> Signed-off-by: Xi Wang <xi.wang@gmail.com>
> ---
>  net/ipv4/devinet.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> index cc06a47..a8e4f26 100644
> --- a/net/ipv4/devinet.c
> +++ b/net/ipv4/devinet.c
> @@ -823,9 +823,9 @@ int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg)
>  		if (!ifa) {
>  			ret = -ENOBUFS;
>  			ifa = inet_alloc_ifa();
> -			INIT_HLIST_NODE(&ifa->hash);
>  			if (!ifa)
>  				break;
> +			INIT_HLIST_NODE(&ifa->hash);
>  			if (colon)
>  				memcpy(ifa->ifa_label, ifr.ifr_name, IFNAMSIZ);
>  			else

Acked-by: Eric Dumazet <edumazet@google.com>

Bug origin : commit fd23c3b31107e2fc483301ee923d8a1db14e53f4
(ipv4: Add hash table of interface addresses) 

in linux-2.6.39

Thanks


--
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
David Miller - Jan. 7, 2013, 5:11 a.m.
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Sat, 05 Jan 2013 15:10:02 -0800

> On Sat, 2013-01-05 at 16:19 -0500, Xi Wang wrote:
>> The NULL pointer check `!ifa' should come before its first use.
>> 
>> Signed-off-by: Xi Wang <xi.wang@gmail.com>
>> ---
>>  net/ipv4/devinet.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
>> index cc06a47..a8e4f26 100644
>> --- a/net/ipv4/devinet.c
>> +++ b/net/ipv4/devinet.c
>> @@ -823,9 +823,9 @@ int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg)
>>  		if (!ifa) {
>>  			ret = -ENOBUFS;
>>  			ifa = inet_alloc_ifa();
>> -			INIT_HLIST_NODE(&ifa->hash);
>>  			if (!ifa)
>>  				break;
>> +			INIT_HLIST_NODE(&ifa->hash);
>>  			if (colon)
>>  				memcpy(ifa->ifa_label, ifr.ifr_name, IFNAMSIZ);
>>  			else
> 
> Acked-by: Eric Dumazet <edumazet@google.com>
> 
> Bug origin : commit fd23c3b31107e2fc483301ee923d8a1db14e53f4
> (ipv4: Add hash table of interface addresses) 
> 
> in linux-2.6.39

Applied and queued up for -stable, thanks.
--
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/net/ipv4/devinet.c b/net/ipv4/devinet.c
index cc06a47..a8e4f26 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -823,9 +823,9 @@  int devinet_ioctl(struct net *net, unsigned int cmd, void __user *arg)
 		if (!ifa) {
 			ret = -ENOBUFS;
 			ifa = inet_alloc_ifa();
-			INIT_HLIST_NODE(&ifa->hash);
 			if (!ifa)
 				break;
+			INIT_HLIST_NODE(&ifa->hash);
 			if (colon)
 				memcpy(ifa->ifa_label, ifr.ifr_name, IFNAMSIZ);
 			else