]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
hv_netvsc: Fix dereference of nvdev before check
authorAndrew Schwartzmeyer <andschwa@microsoft.com>
Wed, 19 Aug 2015 03:06:32 +0000 (20:06 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 19 Aug 2015 03:15:01 +0000 (20:15 -0700)
Passes static analysis by Smatch.

Signed-off-by: Andrew Schwartzmeyer <andschwa@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hyperv/netvsc_drv.c

index f3b9d3eb753b3e48ac689d66314c6e629a651566..2990024b90f972e3e22c56f21d2cce278da651ab 100644 (file)
@@ -777,14 +777,17 @@ static int netvsc_set_channels(struct net_device *net,
        struct hv_device *dev = net_device_ctx->device_ctx;
        struct netvsc_device *nvdev = hv_get_drvdata(dev);
        struct netvsc_device_info device_info;
-       const u32 num_chn = nvdev->num_chn;
-       const u32 max_chn = min_t(u32, nvdev->max_chn, num_online_cpus());
+       u32 num_chn;
+       u32 max_chn;
        int ret = 0;
        bool recovering = false;
 
        if (!nvdev || nvdev->destroy)
                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) {
                pr_info("vRSS unsupported before NVSP Version 5\n");
                return -EINVAL;