All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: hns: dereference ppe_cb->ppe_common_cb if it is non-null
@ 2016-08-25  6:51 Colin King
  2016-08-26  0:42 ` Yisen Zhuang
  2016-08-26 18:45 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2016-08-25  6:51 UTC (permalink / raw)
  To: Yisen Zhuang, Salil Mehta, David S . Miller, Lisheng, netdev; +Cc: linux-kernel

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

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 <colin.king@canonical.com>
---
 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

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

* Re: [PATCH] net: hns: dereference ppe_cb->ppe_common_cb if it is non-null
  2016-08-25  6:51 [PATCH] net: hns: dereference ppe_cb->ppe_common_cb if it is non-null Colin King
@ 2016-08-26  0:42 ` Yisen Zhuang
  2016-08-26 18:45 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Yisen Zhuang @ 2016-08-26  0:42 UTC (permalink / raw)
  To: Colin King, Salil Mehta, David S . Miller, Lisheng, netdev; +Cc: linux-kernel



在 2016/8/25 14:51, Colin King 写道:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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 <colin.king@canonical.com>

Acked-by: Yisen Zhuang <yisen.zhuang@huawei.com>

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

* Re: [PATCH] net: hns: dereference ppe_cb->ppe_common_cb if it is non-null
  2016-08-25  6:51 [PATCH] net: hns: dereference ppe_cb->ppe_common_cb if it is non-null Colin King
  2016-08-26  0:42 ` Yisen Zhuang
@ 2016-08-26 18:45 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-08-26 18:45 UTC (permalink / raw)
  To: colin.king; +Cc: yisen.zhuang, salil.mehta, lisheng011, netdev, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Thu, 25 Aug 2016 07:51:10 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> 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 <colin.king@canonical.com>

Applied.

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

end of thread, other threads:[~2016-08-26 18:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-25  6:51 [PATCH] net: hns: dereference ppe_cb->ppe_common_cb if it is non-null Colin King
2016-08-26  0:42 ` Yisen Zhuang
2016-08-26 18:45 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.