net: hns3: fix null pointer dereference before null check
pointer ndev is being dereferenced with the call to netif_running
before it is being null checked. Re-order the code to only dereference
ndev after it has been null checked.
Detected by CoverityScan, CID#1457206 ("Dereference before null check")
Fixes: 9df8f79a4d
("net: hns3: Add DCB support when interacting with network stack")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
09af87d18f
Коммит
075cfdd659
|
@ -2865,7 +2865,7 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
|
||||||
{
|
{
|
||||||
struct hnae3_knic_private_info *kinfo = &handle->kinfo;
|
struct hnae3_knic_private_info *kinfo = &handle->kinfo;
|
||||||
struct net_device *ndev = kinfo->netdev;
|
struct net_device *ndev = kinfo->netdev;
|
||||||
bool if_running = netif_running(ndev);
|
bool if_running;
|
||||||
int ret;
|
int ret;
|
||||||
u8 i;
|
u8 i;
|
||||||
|
|
||||||
|
@ -2875,6 +2875,8 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
|
||||||
if (!ndev)
|
if (!ndev)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
if_running = netif_running(ndev);
|
||||||
|
|
||||||
ret = netdev_set_num_tc(ndev, tc);
|
ret = netdev_set_num_tc(ndev, tc);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче