diff mbox

ipv4: fix NULL checking in devinet_ioctl()

Message ID 1357420764-12381-1-git-send-email-xi.wang@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Xi Wang Jan. 5, 2013, 9:19 p.m. UTC
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(-)

Comments

Eric Dumazet Jan. 5, 2013, 11:10 p.m. UTC | #1
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. UTC | #2
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
diff mbox

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