Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1609162 > unrolled thread
| Started by | Colin King <colin.king@canonical.com> |
|---|---|
| First post | 2017-03-25 15:30 +0100 |
| Last post | 2017-03-28 01:10 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] netvsc: fix dereference before null check errors Colin King <colin.king@canonical.com> - 2017-03-25 15:30 +0100
RE: [PATCH] netvsc: fix dereference before null check errors Haiyang Zhang <haiyangz@microsoft.com> - 2017-03-27 03:00 +0200
Re: [PATCH] netvsc: fix dereference before null check errors David Miller <davem@davemloft.net> - 2017-03-28 01:10 +0200
| From | Colin King <colin.king@canonical.com> |
|---|---|
| Date | 2017-03-25 15:30 +0100 |
| Subject | [PATCH] netvsc: fix dereference before null check errors |
| Message-ID | <toURz-1ZJ-1@gated-at.bofh.it> |
From: Colin Ian King <colin.king@canonical.com>
ndev is being checked to see if it is a null pointer however before
the null check ndev is being dereferenced; hence there is a potential
null pointer dereference bug that needs fixing. Fix this by only
dereferencing ndev after the null check.
Detected by CoverityScan, CID#1420760, CID#140761 ("Dereference
before null check")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/hyperv/netvsc_drv.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index f830bbbd8ad4..f24c2891dd0c 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -1135,7 +1135,7 @@ static int netvsc_get_rxfh(struct net_device *dev, u32 *indir, u8 *key,
{
struct net_device_context *ndc = netdev_priv(dev);
struct netvsc_device *ndev = rcu_dereference(ndc->nvdev);
- struct rndis_device *rndis_dev = ndev->extension;
+ struct rndis_device *rndis_dev;
int i;
if (!ndev)
@@ -1144,6 +1144,7 @@ static int netvsc_get_rxfh(struct net_device *dev, u32 *indir, u8 *key,
if (hfunc)
*hfunc = ETH_RSS_HASH_TOP; /* Toeplitz */
+ rndis_dev = ndev->extension;
if (indir) {
for (i = 0; i < ITAB_NUM; i++)
indir[i] = rndis_dev->ind_table[i];
@@ -1160,7 +1161,7 @@ static int netvsc_set_rxfh(struct net_device *dev, const u32 *indir,
{
struct net_device_context *ndc = netdev_priv(dev);
struct netvsc_device *ndev = rtnl_dereference(ndc->nvdev);
- struct rndis_device *rndis_dev = ndev->extension;
+ struct rndis_device *rndis_dev;
int i;
if (!ndev)
@@ -1169,6 +1170,7 @@ static int netvsc_set_rxfh(struct net_device *dev, const u32 *indir,
if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
return -EOPNOTSUPP;
+ rndis_dev = ndev->extension;
if (indir) {
for (i = 0; i < ITAB_NUM; i++)
if (indir[i] >= dev->num_rx_queues)
--
2.11.0
[toc] | [next] | [standalone]
| From | Haiyang Zhang <haiyangz@microsoft.com> |
|---|---|
| Date | 2017-03-27 03:00 +0200 |
| Message-ID | <tpraO-86m-9@gated-at.bofh.it> |
| In reply to | #1609162 |
> -----Original Message-----
> From: Colin King [mailto:colin.king@canonical.com]
> Sent: Saturday, March 25, 2017 10:27 AM
> To: KY Srinivasan <kys@microsoft.com>; Haiyang Zhang
> <haiyangz@microsoft.com>; Stephen Hemminger <sthemmin@microsoft.com>;
> devel@linuxdriverproject.org; netdev@vger.kernel.org
> Cc: kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [PATCH] netvsc: fix dereference before null check errors
>
> From: Colin Ian King <colin.king@canonical.com>
>
> ndev is being checked to see if it is a null pointer however before
> the null check ndev is being dereferenced; hence there is a potential
> null pointer dereference bug that needs fixing. Fix this by only
> dereferencing ndev after the null check.
>
> Detected by CoverityScan, CID#1420760, CID#140761 ("Dereference
> before null check")
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Thank you!
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2017-03-28 01:10 +0200 |
| Message-ID | <tpLVT-76v-9@gated-at.bofh.it> |
| In reply to | #1609423 |
From: Haiyang Zhang <haiyangz@microsoft.com>
Date: Mon, 27 Mar 2017 00:50:27 +0000
>
>
>> -----Original Message-----
>> From: Colin King [mailto:colin.king@canonical.com]
>> Sent: Saturday, March 25, 2017 10:27 AM
>> To: KY Srinivasan <kys@microsoft.com>; Haiyang Zhang
>> <haiyangz@microsoft.com>; Stephen Hemminger <sthemmin@microsoft.com>;
>> devel@linuxdriverproject.org; netdev@vger.kernel.org
>> Cc: kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
>> Subject: [PATCH] netvsc: fix dereference before null check errors
>>
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> ndev is being checked to see if it is a null pointer however before
>> the null check ndev is being dereferenced; hence there is a potential
>> null pointer dereference bug that needs fixing. Fix this by only
>> dereferencing ndev after the null check.
>>
>> Detected by CoverityScan, CID#1420760, CID#140761 ("Dereference
>> before null check")
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Applied.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web