net: ethernet: aquantia: Null pointer check for aq_nic_ndev_alloc.
authorPavel Belous <pavel.belous@aquantia.com>
Mon, 20 Feb 2017 19:36:46 +0000 (22:36 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 20 Feb 2017 22:11:09 +0000 (17:11 -0500)
We should check for a null pointer for aq_nic_ndev_alloc
instead netdev_priv.

Signed-off-by: Pavel Belous <pavel.belous@aquantia.com>
Reviewed-by: Lino Sanfilippo <LinoSanfilippo@gmx.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/aquantia/atlantic/aq_nic.c

index 019bcc725715f977e71bc670fd3cc263eb8e8b8a..a8a27c5e8aebc1612349754f91f7f35924b8ce55 100644 (file)
@@ -202,12 +202,13 @@ struct aq_nic_s *aq_nic_alloc_cold(const struct net_device_ops *ndev_ops,
        int err = 0;
 
        ndev = aq_nic_ndev_alloc();
-       self = netdev_priv(ndev);
-       if (!self) {
-               err = -EINVAL;
+       if (!ndev) {
+               err = -ENOMEM;
                goto err_exit;
        }
 
+       self = netdev_priv(ndev);
+
        ndev->netdev_ops = ndev_ops;
        ndev->ethtool_ops = et_ops;