提交 08a82788 编写于 作者: C Colin Ian King 提交者: Yang Yingliang

net: hns3: Fix potential null pointer defererence of null ae_dev

mainline inclusion
from mainline-v5.13-rc1
commit d0494135
category: bugfix
bugzilla: NA
CVE: NA

----------------------------

The reset_prepare and reset_done calls have a null pointer check
on ae_dev however ae_dev is being dereferenced via the call to
ns3_is_phys_func with the ae->pdev argument. Fix this by performing
a null pointer check on ae_dev and hence short-circuiting the
dereference to ae_dev on the call to ns3_is_phys_func.

Addresses-Coverity: ("Dereference before null check")
Fixes: 715c58e9 ("net: hns3: add suspend and resume pm_ops")
Signed-off-by: NColin Ian King <colin.king@canonical.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NYonglong Liu <liuyonglong@huawei.com>
Reviewed-by: Nli yongxin <liyongxin1@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 9e60f195
...@@ -2280,9 +2280,9 @@ static int __maybe_unused hns3_suspend(struct device *dev) ...@@ -2280,9 +2280,9 @@ static int __maybe_unused hns3_suspend(struct device *dev)
{ {
struct hnae3_ae_dev *ae_dev = dev_get_drvdata(dev); struct hnae3_ae_dev *ae_dev = dev_get_drvdata(dev);
if (hns3_is_phys_func(ae_dev->pdev)) { if (ae_dev && hns3_is_phys_func(ae_dev->pdev)) {
dev_info(dev, "Begin to suspend.\n"); dev_info(dev, "Begin to suspend.\n");
if (ae_dev && ae_dev->ops && ae_dev->ops->reset_prepare) if (ae_dev->ops && ae_dev->ops->reset_prepare)
ae_dev->ops->reset_prepare(ae_dev, HNAE3_FUNC_RESET); ae_dev->ops->reset_prepare(ae_dev, HNAE3_FUNC_RESET);
} }
...@@ -2293,9 +2293,9 @@ static int __maybe_unused hns3_resume(struct device *dev) ...@@ -2293,9 +2293,9 @@ static int __maybe_unused hns3_resume(struct device *dev)
{ {
struct hnae3_ae_dev *ae_dev = dev_get_drvdata(dev); struct hnae3_ae_dev *ae_dev = dev_get_drvdata(dev);
if (hns3_is_phys_func(ae_dev->pdev)) { if (ae_dev && hns3_is_phys_func(ae_dev->pdev)) {
dev_info(dev, "Begin to resume.\n"); dev_info(dev, "Begin to resume.\n");
if (ae_dev && ae_dev->ops && ae_dev->ops->reset_done) if (ae_dev->ops && ae_dev->ops->reset_done)
ae_dev->ops->reset_done(ae_dev); ae_dev->ops->reset_done(ae_dev);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册