[PATCH] net: hns: dereference ppe_cb->ppe_common_cb if it is non-null

Subsystems: hisilicon network subsystem driver, networking drivers, the rest

STALE3655d

3 messages, 3 authors, 2016-08-26 · open the first message on its own page

[PATCH] net: hns: dereference ppe_cb->ppe_common_cb if it is non-null

From: Colin King <hidden>
Date: 2016-08-25 06:52:29

From: Colin Ian King <redacted>

ppe_cb->ppe_common_cb is being dereferenced before a null check is
being made on it.  If ppe_cb->ppe_common_cb is null then we end up
with a null pointer dereference when assigning dsaf_dev.  Fix this
by moving the initialisation of dsaf_dev once we know
ppe_cb->ppe_common_cb is OK to dereference.

Signed-off-by: Colin Ian King <redacted>
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
index ff8b6a4..6ea8722 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
@@ -328,9 +328,10 @@ static void hns_ppe_init_hw(struct hns_ppe_cb *ppe_cb)
 static void hns_ppe_uninit_hw(struct hns_ppe_cb *ppe_cb)
 {
 	u32 port;
-	struct dsaf_device *dsaf_dev = ppe_cb->ppe_common_cb->dsaf_dev;
 
 	if (ppe_cb->ppe_common_cb) {
+		struct dsaf_device *dsaf_dev = ppe_cb->ppe_common_cb->dsaf_dev;
+
 		port = ppe_cb->index;
 		dsaf_dev->misc_op->ppe_srst(dsaf_dev, port, 0);
 	}
-- 
2.9.3

Re: [PATCH] net: hns: dereference ppe_cb->ppe_common_cb if it is non-null

From: Yisen Zhuang <hidden>
Date: 2016-08-26 00:42:44


在 2016/8/25 14:51, Colin King 写道:
From: Colin Ian King <redacted>

ppe_cb->ppe_common_cb is being dereferenced before a null check is
being made on it.  If ppe_cb->ppe_common_cb is null then we end up
with a null pointer dereference when assigning dsaf_dev.  Fix this
by moving the initialisation of dsaf_dev once we know
ppe_cb->ppe_common_cb is OK to dereference.

Signed-off-by: Colin Ian King <redacted>
Acked-by: Yisen Zhuang <redacted>

Re: [PATCH] net: hns: dereference ppe_cb->ppe_common_cb if it is non-null

From: David Miller <davem@davemloft.net>
Date: 2016-08-26 18:45:47

From: Colin King <redacted>
Date: Thu, 25 Aug 2016 07:51:10 +0100
From: Colin Ian King <redacted>

ppe_cb->ppe_common_cb is being dereferenced before a null check is
being made on it.  If ppe_cb->ppe_common_cb is null then we end up
with a null pointer dereference when assigning dsaf_dev.  Fix this
by moving the initialisation of dsaf_dev once we know
ppe_cb->ppe_common_cb is OK to dereference.

Signed-off-by: Colin Ian King <redacted>
Applied.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help