kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] net: hns3: fix dereference of ae_dev before it is null checked
@ 2019-06-17 11:42 Colin King
  2019-06-17 21:05 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2019-06-17 11:42 UTC (permalink / raw)
  To: Yisen Zhuang, Salil Mehta, David S . Miller, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Pointer ae_dev is null checked however, prior to that it is dereferenced
when assigned pointer ops. Fix this by assigning pointer ops after ae_dev
has been null checked.

Addresses-Coverity: ("Dereference before null check")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 951a8125ea0c..58633cdcdcfd 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1940,13 +1940,14 @@ static pci_ers_result_t hns3_error_detected(struct pci_dev *pdev,
 static pci_ers_result_t hns3_slot_reset(struct pci_dev *pdev)
 {
 	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev);
-	const struct hnae3_ae_ops *ops = ae_dev->ops;
+	const struct hnae3_ae_ops *ops;
 	enum hnae3_reset_type reset_type;
 	struct device *dev = &pdev->dev;
 
 	if (!ae_dev || !ae_dev->ops)
 		return PCI_ERS_RESULT_NONE;
 
+	ops = ae_dev->ops;
 	/* request the reset */
 	if (ops->reset_event) {
 		if (!ae_dev->override_pci_need_reset) {
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] net: hns3: fix dereference of ae_dev before it is null checked
  2019-06-17 11:42 [PATCH][next] net: hns3: fix dereference of ae_dev before it is null checked Colin King
@ 2019-06-17 21:05 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-06-17 21:05 UTC (permalink / raw)
  To: colin.king
  Cc: yisen.zhuang, salil.mehta, netdev, kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Mon, 17 Jun 2019 12:42:14 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> Pointer ae_dev is null checked however, prior to that it is dereferenced
> when assigned pointer ops. Fix this by assigning pointer ops after ae_dev
> has been null checked.
> 
> Addresses-Coverity: ("Dereference before null check")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-17 21:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-17 11:42 [PATCH][next] net: hns3: fix dereference of ae_dev before it is null checked Colin King
2019-06-17 21:05 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).