netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarek Poplawski <jarkao2@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Linux Netdev List <netdev@vger.kernel.org>
Subject: Re: [RFC, PATCH] net: suspicious test in dev_change_name()
Date: Sat, 31 Oct 2009 00:50:09 +0100	[thread overview]
Message-ID: <4AEB7BB1.9000901@gmail.com> (raw)
In-Reply-To: <4AEAAFC4.9050309@gmail.com>

Eric Dumazet wrote, On 10/30/2009 10:20 AM:

> While preparing a patch for net-next-2.6, I noticed following code in dev_change_name()
> 
> int err = 0;
> ...
>         ret = call_netdevice_notifiers(NETDEV_CHANGENAME, dev);
>         ret = notifier_to_errno(ret);
> 
>         if (ret) {
> << HERE >>      if (err) {
>                         printk(KERN_ERR
>                                "%s: name change rollback failed: %d.\n",
>                                dev->name, ret);
>                 } else {
>                         err = ret;
>                         memcpy(dev->name, oldname, IFNAMSIZ);
>                         goto rollback;
>                 }
>         }
> 
> 
> It seems intent was to test if notifier_to_errno() was null ?


I don't think so: err stores the previous ret meaning rollback and
is checked for this later. But somebody forgot err can store previous
(positive) value here, so IMHO you're right: there is a bug in this
place ;-)

Jarek P.

> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> ---
> 
> diff --git a/net/core/dev.c b/net/core/dev.c
> index b8f74cf..029cd41 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -939,9 +939,9 @@ rollback:
>  	write_unlock_bh(&dev_base_lock);
>  
>  	ret = call_netdevice_notifiers(NETDEV_CHANGENAME, dev);
> -	ret = notifier_to_errno(ret);
>  
>  	if (ret) {
> +		err = notifier_to_errno(ret);
>  		if (err) {
>  			printk(KERN_ERR
>  			       "%s: name change rollback failed: %d.\n",
> --
> 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
> 



  reply	other threads:[~2009-10-30 23:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-30  9:20 [RFC, PATCH] net: suspicious test in dev_change_name() Eric Dumazet
2009-10-30 23:50 ` Jarek Poplawski [this message]
2009-11-02  8:05   ` David Miller
2009-11-16  9:30     ` [PATCH net] net: Fix the rollback " Jarek Poplawski
2009-11-16 10:49       ` David Miller
2009-11-16 11:08         ` Eric Dumazet
2009-11-16 11:31           ` 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=4AEB7BB1.9000901@gmail.com \
    --to=jarkao2@gmail.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).