提交 d212b463 编写于 作者: H Haiyang Zhang 提交者: David S. Miller

hv_netvsc: Fix accessing freed memory in netvsc_change_mtu()

struct netvsc_device is freed in rndis_filter_device_remove(). So we save
the nvdev->num_chn into a temp variable for later usage.

(Please also include this patch into stable branch.)
Signed-off-by: NHaiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: NK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 1f461dcd
...@@ -858,6 +858,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) ...@@ -858,6 +858,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
struct netvsc_device *nvdev = hv_get_drvdata(hdev); struct netvsc_device *nvdev = hv_get_drvdata(hdev);
struct netvsc_device_info device_info; struct netvsc_device_info device_info;
int limit = ETH_DATA_LEN; int limit = ETH_DATA_LEN;
u32 num_chn;
int ret = 0; int ret = 0;
if (nvdev == NULL || nvdev->destroy) if (nvdev == NULL || nvdev->destroy)
...@@ -873,6 +874,8 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) ...@@ -873,6 +874,8 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
if (ret) if (ret)
goto out; goto out;
num_chn = nvdev->num_chn;
nvdev->start_remove = true; nvdev->start_remove = true;
rndis_filter_device_remove(hdev); rndis_filter_device_remove(hdev);
...@@ -883,7 +886,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) ...@@ -883,7 +886,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
memset(&device_info, 0, sizeof(device_info)); memset(&device_info, 0, sizeof(device_info));
device_info.ring_size = ring_size; device_info.ring_size = ring_size;
device_info.num_chn = nvdev->num_chn; device_info.num_chn = num_chn;
device_info.max_num_vrss_chns = max_num_vrss_chns; device_info.max_num_vrss_chns = max_num_vrss_chns;
rndis_filter_device_add(hdev, &device_info); rndis_filter_device_add(hdev, &device_info);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册