Browse Source

net: ethernet: aquantia: Null pointer check for aq_nic_ndev_alloc.

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>
Pavel Belous 8 years ago
parent
commit
df9000ef96
1 changed files with 4 additions and 3 deletions
  1. 4 3
      drivers/net/ethernet/aquantia/atlantic/aq_nic.c

+ 4 - 3
drivers/net/ethernet/aquantia/atlantic/aq_nic.c

@@ -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;