[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <DM6PR21MB13374BEBDDCFA4CE76D89E31CAAD0@DM6PR21MB1337.namprd21.prod.outlook.com>
Date: Wed, 14 Aug 2019 20:35:17 +0000
From: Haiyang Zhang <haiyangz@...rosoft.com>
To: Wenwen Wang <wenwen@...uga.edu>
CC: KY Srinivasan <kys@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
Sasha Levin <sashal@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
"open list:Hyper-V CORE AND DRIVERS" <linux-hyperv@...r.kernel.org>,
"open list:NETWORKING DRIVERS" <netdev@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] hv_netvsc: Fix a memory leak bug
> -----Original Message-----
> From: Wenwen Wang <wenwen@...uga.edu>
> Sent: Wednesday, August 14, 2019 4:16 PM
> To: Wenwen Wang <wenwen@...uga.edu>
> Cc: KY Srinivasan <kys@...rosoft.com>; Haiyang Zhang
> <haiyangz@...rosoft.com>; Stephen Hemminger
> <sthemmin@...rosoft.com>; Sasha Levin <sashal@...nel.org>; David S.
> Miller <davem@...emloft.net>; open list:Hyper-V CORE AND DRIVERS
> <linux-hyperv@...r.kernel.org>; open list:NETWORKING DRIVERS
> <netdev@...r.kernel.org>; open list <linux-kernel@...r.kernel.org>
> Subject: [PATCH] hv_netvsc: Fix a memory leak bug
>
> In rndis_filter_device_add(), 'rndis_device' is allocated through kzalloc()
> by invoking get_rndis_device(). In the following execution, if an error
> occurs, the execution will go to the 'err_dev_remv' label. However, the
> allocated 'rndis_device' is not deallocated, leading to a memory leak bug.
>
> Signed-off-by: Wenwen Wang <wenwen@...uga.edu>
> ---
> drivers/net/hyperv/rndis_filter.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/hyperv/rndis_filter.c
> b/drivers/net/hyperv/rndis_filter.c
> index 317dbe9..ed35085 100644
> --- a/drivers/net/hyperv/rndis_filter.c
> +++ b/drivers/net/hyperv/rndis_filter.c
> @@ -1420,6 +1420,7 @@ struct netvsc_device
> *rndis_filter_device_add(struct hv_device *dev,
>
> err_dev_remv:
> rndis_filter_device_remove(dev, net_device);
> + kfree(rndis_device);
The kfree() is not necessary here.
Because it is already freed by --
rndis_filter_device_remove() --> netvsc_device_remove()
--> free_netvsc_device_rcu() --> free_netvsc_device()
--> kfree(nvdev->extension); //This frees rndis_device.
Thanks,
- Haiyang
Powered by blists - more mailing lists