[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a7c5884d-2c7d-1868-8b93-414b43b3f7c1@hartkopp.net>
Date: Thu, 22 Oct 2020 19:34:14 +0200
From: Oliver Hartkopp <socketcan@...tkopp.net>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Dinghao Liu <dinghao.liu@....edu.cn>, kjlu@....edu,
Wolfgang Grandegger <wg@...ndegger.com>,
Marc Kleine-Budde <mkl@...gutronix.de>,
"David S. Miller" <davem@...emloft.net>, linux-can@...r.kernel.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] can: vxcan: Fix memleak in vxcan_newlink
On 22.10.20 18:14, Jakub Kicinski wrote:
> On Wed, 21 Oct 2020 13:20:16 +0200 Oliver Hartkopp wrote:
>> On 21.10.20 07:21, Dinghao Liu wrote:
>>> When rtnl_configure_link() fails, peer needs to be
>>> freed just like when register_netdevice() fails.
>>>
>>> Signed-off-by: Dinghao Liu <dinghao.liu@....edu.cn>
>>
>> Acked-by: Oliver Hartkopp <socketcan@...tkopp.net>
>>
>> Btw. as the vxcan.c driver bases on veth.c the same issue can be found
>> there!
>>
>> At this point:
>> https://elixir.bootlin.com/linux/latest/source/drivers/net/veth.c#L1398
>>
>> err_register_dev:
>> /* nothing to do */
>> err_configure_peer:
>> unregister_netdevice(peer);
>> return err; <<<<<<<<<<<<<<<<<<<<<<<
>>
>> err_register_peer:
>> free_netdev(peer);
>> return err;
>> }
>>
>> IMO the return must be removed to fall through the next label and free
>> the netdevice too.
>>
>> Would you like so send a patch for veth.c too?
>
> Ah, this is where Liu Dinghao got the veth suggestion :)
>
> Does vxcan actually need this patch?
>
> static void vxcan_setup(struct net_device *dev)
> {
> [...]
> dev->needs_free_netdev = true;
>
Oh!
In fact the vxcan.c is really similar to veth.c in these code snippets -
so I wondered why this never had been seen in veth.c.
Then vxcan.c doesn't need that patch too :-/
Thanks for the heads up!
@Marc: Can you please make sure that it doesn't get into upstream? Tnx!
Best,
Oliver
Powered by blists - more mailing lists