提交 b3c6132f 编写于 作者: Y Yunsheng Lin 提交者: Xie XiuQi

net: hns3: fix for dereferencing before null checking

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

The netdev is dereferenced before null checking in the function
hns3_setup_tc.

This patch moves the dereferencing after the null checking.

Fixes: 76ad4f0e ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC")

Feature or Bugfix:Bugfix
Signed-off-by: NYunsheng Lin <linyunsheng@huawei.com>
Reviewed-by: Nliuyonglong <liuyonglong@huawei.com>
Reviewed-by: Nlipeng <lipeng321@huawei.com>
Reviewed-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 a6ed1fec
...@@ -1559,12 +1559,12 @@ static struct rtnl_link_stats64 *hns3_nic_get_stats64(struct net_device *netdev, ...@@ -1559,12 +1559,12 @@ static struct rtnl_link_stats64 *hns3_nic_get_stats64(struct net_device *netdev,
static int hns3_setup_tc(struct net_device *netdev, void *type_data) static int hns3_setup_tc(struct net_device *netdev, void *type_data)
{ {
struct tc_mqprio_qopt_offload *mqprio_qopt = type_data; struct tc_mqprio_qopt_offload *mqprio_qopt = type_data;
struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_knic_private_info *kinfo = &h->kinfo;
u8 *prio_tc = mqprio_qopt->qopt.prio_tc_map; u8 *prio_tc = mqprio_qopt->qopt.prio_tc_map;
struct hnae3_knic_private_info *kinfo;
u8 tc = mqprio_qopt->qopt.num_tc; u8 tc = mqprio_qopt->qopt.num_tc;
u16 mode = mqprio_qopt->mode; u16 mode = mqprio_qopt->mode;
u8 hw = mqprio_qopt->qopt.hw; u8 hw = mqprio_qopt->qopt.hw;
struct hnae3_handle *h;
if (!((hw == TC_MQPRIO_HW_OFFLOAD_TCS && if (!((hw == TC_MQPRIO_HW_OFFLOAD_TCS &&
mode == TC_MQPRIO_MODE_CHANNEL) || (!hw && tc == 0))) mode == TC_MQPRIO_MODE_CHANNEL) || (!hw && tc == 0)))
...@@ -1576,6 +1576,9 @@ static int hns3_setup_tc(struct net_device *netdev, void *type_data) ...@@ -1576,6 +1576,9 @@ static int hns3_setup_tc(struct net_device *netdev, void *type_data)
if (!netdev) if (!netdev)
return -EINVAL; return -EINVAL;
h = hns3_get_handle(netdev);
kinfo = &h->kinfo;
return (kinfo->dcb_ops && kinfo->dcb_ops->setup_tc) ? return (kinfo->dcb_ops && kinfo->dcb_ops->setup_tc) ?
kinfo->dcb_ops->setup_tc(h, tc, prio_tc) : -EOPNOTSUPP; kinfo->dcb_ops->setup_tc(h, tc, prio_tc) : -EOPNOTSUPP;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册