hyperv: NULL dereference on error
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 4 Sep 2014 11:11:23 +0000 (14:11 +0300)
committerDavid S. Miller <davem@davemloft.net>
Sat, 6 Sep 2014 00:29:22 +0000 (17:29 -0700)
We try to call free_netvsc_device(net_device) when "net_device" is NULL.
It leads to an Oops.

Fixes: f90251c8a6d0 ('hyperv: Increase the buffer length for netvsc_channel_cb()')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hyperv/netvsc.c

index 5b5644a2233cc0d3e1791349080909773de16346..977984bc238a1e0cc374c6ef5fd08f07546369d9 100644 (file)
@@ -1054,10 +1054,8 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
        struct net_device *ndev;
 
        net_device = alloc_net_device(device);
-       if (!net_device) {
-               ret = -ENOMEM;
-               goto cleanup;
-       }
+       if (!net_device)
+               return -ENOMEM;
 
        net_device->ring_size = ring_size;