Commit 954591b9 authored by Andrew Schwartzmeyer's avatar Andrew Schwartzmeyer Committed by David S. Miller

hv_netvsc: Fix dereference of nvdev before check

Passes static analysis by Smatch.
Signed-off-by: default avatarAndrew Schwartzmeyer <andschwa@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2d798499
...@@ -777,14 +777,17 @@ static int netvsc_set_channels(struct net_device *net, ...@@ -777,14 +777,17 @@ static int netvsc_set_channels(struct net_device *net,
struct hv_device *dev = net_device_ctx->device_ctx; struct hv_device *dev = net_device_ctx->device_ctx;
struct netvsc_device *nvdev = hv_get_drvdata(dev); struct netvsc_device *nvdev = hv_get_drvdata(dev);
struct netvsc_device_info device_info; struct netvsc_device_info device_info;
const u32 num_chn = nvdev->num_chn; u32 num_chn;
const u32 max_chn = min_t(u32, nvdev->max_chn, num_online_cpus()); u32 max_chn;
int ret = 0; int ret = 0;
bool recovering = false; bool recovering = false;
if (!nvdev || nvdev->destroy) if (!nvdev || nvdev->destroy)
return -ENODEV; return -ENODEV;
num_chn = nvdev->num_chn;
max_chn = min_t(u32, nvdev->max_chn, num_online_cpus());
if (nvdev->nvsp_version < NVSP_PROTOCOL_VERSION_5) { if (nvdev->nvsp_version < NVSP_PROTOCOL_VERSION_5) {
pr_info("vRSS unsupported before NVSP Version 5\n"); pr_info("vRSS unsupported before NVSP Version 5\n");
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment