[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230214132331.526f4fb7@kernel.org>
Date: Tue, 14 Feb 2023 13:23:31 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Gong Ruiqi <gongruiqi1@...wei.com>
Cc: <davem@...emloft.net>, <netdev@...r.kernel.org>,
<edumazet@...gle.com>, <pabeni@...hat.com>,
lianhui tang <bluetlh@...il.com>, <kuniyu@...zon.co.jp>,
<rshearma@...cade.com>
Subject: Re: [PATCH net] net: mpls: fix stale pointer if allocation fails
during device rename
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.
Powered by blists - more mailing lists