]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ice: fix kernel BUG if register_netdev fails
authorJacob Keller <jacob.e.keller@intel.com>
Sat, 16 May 2020 00:42:25 +0000 (17:42 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Thu, 28 May 2020 22:51:28 +0000 (15:51 -0700)
If register_netdev() fails, the driver will attempt to cleanup the
q_vectors and inadvertently trigger a kernel BUG due to a NULL pointer
dereference.

This occurs because cleaning up q_vectors attempts to call
netif_napi_del on napi_structs which were never initialized.

Resolve this by releasing the netdev in ice_cfg_netdev and setting
vsi->netdev to NULL. This ensures that after ice_cfg_netdev fails the
state is rewound to match as if ice_cfg_netdev was never called.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ice/ice_main.c

index 5cffaf360cb043001f630c489766e5b9d2b0169c..69854b8644a68c4c3d65c96f321cfee730f2a083 100644 (file)
@@ -2428,7 +2428,7 @@ static int ice_cfg_netdev(struct ice_vsi *vsi)
 
        err = register_netdev(vsi->netdev);
        if (err)
-               goto err_destroy_devlink_port;
+               goto err_free_netdev;
 
        devlink_port_type_eth_set(&pf->devlink_port, vsi->netdev);
 
@@ -2439,9 +2439,11 @@ static int ice_cfg_netdev(struct ice_vsi *vsi)
 
        return 0;
 
+err_free_netdev:
+       free_netdev(vsi->netdev);
+       vsi->netdev = NULL;
 err_destroy_devlink_port:
        ice_devlink_destroy_port(pf);
-
        return err;
 }