netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Gong Ruiqi <gongruiqi1@huawei.com>
Cc: <davem@davemloft.net>, <netdev@vger.kernel.org>,
	<edumazet@google.com>, <pabeni@redhat.com>,
	lianhui tang <bluetlh@gmail.com>, <kuniyu@amazon.co.jp>,
	<rshearma@brocade.com>
Subject: Re: [PATCH net] net: mpls: fix stale pointer if allocation fails during device rename
Date: Tue, 14 Feb 2023 13:23:31 -0800	[thread overview]
Message-ID: <20230214132331.526f4fb7@kernel.org> (raw)
In-Reply-To: <d85f25cf-3c37-dff2-85fd-f8f3a5a57645@huawei.com>

On Tue, 14 Feb 2023 17:33:36 +0800 Gong Ruiqi wrote:
> Just be curious: would this be a simpler solution?
> 
> @@ -1439,6 +1439,7 @@ static void mpls_dev_sysctl_unregister(struct
> net_device *dev,
> 
>         table = mdev->sysctl->ctl_table_arg;
>         unregister_net_sysctl_table(mdev->sysctl);
> +       mdev->sysctl = NULL;
>         kfree(table);
> 
>         mpls_netconf_notify_devconf(net, RTM_DELNETCONF, 0, mdev);
> 
> However I'm not sure if we need to preserve the old value of
> mdev->sysctl after we unregister it.

It'd work too, I decided to limit the zeroing to the exception case
because of recent discussions on the list. The argument there was that
zeroing in cases were we don't expect it to be necessary may hide bugs.
We generally try to avoid defensive programming in the kernel.

  reply	other threads:[~2023-02-14 21:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14  6:53 [PATCH net] net: mpls: fix stale pointer if allocation fails during device rename Jakub Kicinski
2023-02-14  9:33 ` Gong Ruiqi
2023-02-14 21:23   ` Jakub Kicinski [this message]
2023-02-15  6:29     ` Gong Ruiqi
2023-02-15 10:30 ` patchwork-bot+netdevbpf

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=20230214132331.526f4fb7@kernel.org \
    --to=kuba@kernel.org \
    --cc=bluetlh@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gongruiqi1@huawei.com \
    --cc=kuniyu@amazon.co.jp \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rshearma@brocade.com \
    /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).