* [PATCH] net: hns3: fix null pointer dereference before null check
@ 2017-09-29 19:51 ` Colin King
0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2017-09-29 19:51 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 ndev is being dereferenced with the call to netif_running
before it is being null checked. Re-order the code to only dereference
ndev after it has been null checked.
Detected by CoverityScan, CID#1457206 ("Dereference before null check")
Fixes: 9df8f79a4d29 ("net: hns3: Add DCB support when interacting with network stack")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
index 4a0890f98b70..c31506514e5d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
@@ -2865,7 +2865,7 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
{
struct hnae3_knic_private_info *kinfo = &handle->kinfo;
struct net_device *ndev = kinfo->netdev;
- bool if_running = netif_running(ndev);
+ bool if_running;
int ret;
u8 i;
@@ -2875,6 +2875,8 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
if (!ndev)
return -ENODEV;
+ if_running = netif_running(ndev);
+
ret = netdev_set_num_tc(ndev, tc);
if (ret)
return ret;
--
2.14.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] net: hns3: fix null pointer dereference before null check
@ 2017-09-29 19:51 ` Colin King
0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2017-09-29 19:51 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 ndev is being dereferenced with the call to netif_running
before it is being null checked. Re-order the code to only dereference
ndev after it has been null checked.
Detected by CoverityScan, CID#1457206 ("Dereference before null check")
Fixes: 9df8f79a4d29 ("net: hns3: Add DCB support when interacting with network stack")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
index 4a0890f98b70..c31506514e5d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
@@ -2865,7 +2865,7 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
{
struct hnae3_knic_private_info *kinfo = &handle->kinfo;
struct net_device *ndev = kinfo->netdev;
- bool if_running = netif_running(ndev);
+ bool if_running;
int ret;
u8 i;
@@ -2875,6 +2875,8 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
if (!ndev)
return -ENODEV;
+ if_running = netif_running(ndev);
+
ret = netdev_set_num_tc(ndev, tc);
if (ret)
return ret;
--
2.14.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] net: hns3: fix null pointer dereference before null check
2017-09-29 19:51 ` Colin King
@ 2017-09-30 0:43 ` Yunsheng Lin
-1 siblings, 0 replies; 6+ messages in thread
From: Yunsheng Lin @ 2017-09-30 0:43 UTC (permalink / raw)
To: Colin King, Yisen Zhuang, Salil Mehta, David S . Miller, netdev
Cc: kernel-janitors, linux-kernel
Hi, Colin
On 2017/9/30 3:51, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> pointer ndev is being dereferenced with the call to netif_running
> before it is being null checked. Re-order the code to only dereference
> ndev after it has been null checked.
Thanks for fixing it.
>
> Detected by CoverityScan, CID#1457206 ("Dereference before null check")
>
> Fixes: 9df8f79a4d29 ("net: hns3: Add DCB support when interacting with network stack")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
> index 4a0890f98b70..c31506514e5d 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
> @@ -2865,7 +2865,7 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
> {
> struct hnae3_knic_private_info *kinfo = &handle->kinfo;
> struct net_device *ndev = kinfo->netdev;
> - bool if_running = netif_running(ndev);
> + bool if_running;
> int ret;
> u8 i;
>
> @@ -2875,6 +2875,8 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
> if (!ndev)
> return -ENODEV;
>
> + if_running = netif_running(ndev);
> +
> ret = netdev_set_num_tc(ndev, tc);
> if (ret)
> return ret;
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: hns3: fix null pointer dereference before null check
@ 2017-09-30 0:43 ` Yunsheng Lin
0 siblings, 0 replies; 6+ messages in thread
From: Yunsheng Lin @ 2017-09-30 0:43 UTC (permalink / raw)
To: Colin King, Yisen Zhuang, Salil Mehta, David S . Miller, netdev
Cc: kernel-janitors, linux-kernel
Hi, Colin
On 2017/9/30 3:51, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> pointer ndev is being dereferenced with the call to netif_running
> before it is being null checked. Re-order the code to only dereference
> ndev after it has been null checked.
Thanks for fixing it.
>
> Detected by CoverityScan, CID#1457206 ("Dereference before null check")
>
> Fixes: 9df8f79a4d29 ("net: hns3: Add DCB support when interacting with network stack")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
> index 4a0890f98b70..c31506514e5d 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
> @@ -2865,7 +2865,7 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
> {
> struct hnae3_knic_private_info *kinfo = &handle->kinfo;
> struct net_device *ndev = kinfo->netdev;
> - bool if_running = netif_running(ndev);
> + bool if_running;
> int ret;
> u8 i;
>
> @@ -2875,6 +2875,8 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
> if (!ndev)
> return -ENODEV;
>
> + if_running = netif_running(ndev);
> +
> ret = netdev_set_num_tc(ndev, tc);
> if (ret)
> return ret;
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: hns3: fix null pointer dereference before null check
2017-09-29 19:51 ` Colin King
@ 2017-10-01 3:13 ` David Miller
-1 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2017-10-01 3:13 UTC (permalink / raw)
To: colin.king
Cc: yisen.zhuang, salil.mehta, netdev, kernel-janitors, linux-kernel
From: Colin King <colin.king@canonical.com>
Date: Fri, 29 Sep 2017 20:51:23 +0100
> From: Colin Ian King <colin.king@canonical.com>
>
> pointer ndev is being dereferenced with the call to netif_running
> before it is being null checked. Re-order the code to only dereference
> ndev after it has been null checked.
>
> Detected by CoverityScan, CID#1457206 ("Dereference before null check")
>
> Fixes: 9df8f79a4d29 ("net: hns3: Add DCB support when interacting with network stack")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Applied.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: hns3: fix null pointer dereference before null check
@ 2017-10-01 3:13 ` David Miller
0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2017-10-01 3:13 UTC (permalink / raw)
To: colin.king
Cc: yisen.zhuang, salil.mehta, netdev, kernel-janitors, linux-kernel
From: Colin King <colin.king@canonical.com>
Date: Fri, 29 Sep 2017 20:51:23 +0100
> From: Colin Ian King <colin.king@canonical.com>
>
> pointer ndev is being dereferenced with the call to netif_running
> before it is being null checked. Re-order the code to only dereference
> ndev after it has been null checked.
>
> Detected by CoverityScan, CID#1457206 ("Dereference before null check")
>
> Fixes: 9df8f79a4d29 ("net: hns3: Add DCB support when interacting with network stack")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Applied.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-10-01 3:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-29 19:51 [PATCH] net: hns3: fix null pointer dereference before null check Colin King
2017-09-29 19:51 ` Colin King
2017-09-30 0:43 ` Yunsheng Lin
2017-09-30 0:43 ` Yunsheng Lin
2017-10-01 3:13 ` David Miller
2017-10-01 3:13 ` 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.