Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1402567 > unrolled thread
| Started by | Heinrich Schuchardt <xypron.glpk@gmx.de> |
|---|---|
| First post | 2016-05-17 22:10 +0200 |
| Last post | 2016-05-19 20:30 +0200 |
| Articles | 6 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH 1/1] net: hns: avoid null pointer dereference Heinrich Schuchardt <xypron.glpk@gmx.de> - 2016-05-17 22:10 +0200
Re: [PATCH 1/1] net: hns: avoid null pointer dereference Yisen Zhuang <Yisen.zhuang@huawei.com> - 2016-05-18 03:10 +0200
RE: [PATCH 1/1] net: hns: avoid null pointer dereference David Laight <David.Laight@ACULAB.COM> - 2016-05-19 13:20 +0200
[PATCH v2 1/1] net: hns: avoid null pointer dereference Heinrich Schuchardt <xypron.glpk@gmx.de> - 2016-05-19 21:30 +0200
Re: [PATCH v2 1/1] net: hns: avoid null pointer dereference David Miller <davem@davemloft.net> - 2016-05-23 23:00 +0200
Re: [PATCH 1/1] net: hns: avoid null pointer dereference David Miller <davem@davemloft.net> - 2016-05-19 20:30 +0200
| From | Heinrich Schuchardt <xypron.glpk@gmx.de> |
|---|---|
| Date | 2016-05-17 22:10 +0200 |
| Subject | [PATCH 1/1] net: hns: avoid null pointer dereference |
| Message-ID | <rzTtv-HV-3@gated-at.bofh.it> |
In the statement
assert(priv || priv->ae_handle);
the right side of || is only evaluated if priv is null.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
index 3d746c8..834a50a 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
@@ -720,7 +720,7 @@ static int hns_set_pauseparam(struct net_device *net_dev,
struct hnae_handle *h;
struct hnae_ae_ops *ops;
- assert(priv || priv->ae_handle);
+ assert(priv && priv->ae_handle);
h = priv->ae_handle;
ops = h->dev->ops;
@@ -780,7 +780,7 @@ static int hns_set_coalesce(struct net_device *net_dev,
struct hnae_ae_ops *ops;
int ret;
- assert(priv || priv->ae_handle);
+ assert(priv && priv->ae_handle);
ops = priv->ae_handle->dev->ops;
@@ -1111,7 +1111,7 @@ void hns_get_regs(struct net_device *net_dev, struct ethtool_regs *cmd,
struct hns_nic_priv *priv = netdev_priv(net_dev);
struct hnae_ae_ops *ops;
- assert(priv || priv->ae_handle);
+ assert(priv && priv->ae_handle);
ops = priv->ae_handle->dev->ops;
@@ -1135,7 +1135,7 @@ static int hns_get_regs_len(struct net_device *net_dev)
struct hns_nic_priv *priv = netdev_priv(net_dev);
struct hnae_ae_ops *ops;
- assert(priv || priv->ae_handle);
+ assert(priv && priv->ae_handle);
ops = priv->ae_handle->dev->ops;
if (!ops->get_regs_len) {
--
2.1.4
[toc] | [next] | [standalone]
| From | Yisen Zhuang <Yisen.zhuang@huawei.com> |
|---|---|
| Date | 2016-05-18 03:10 +0200 |
| Message-ID | <rzY9Q-3C3-3@gated-at.bofh.it> |
| In reply to | #1402567 |
Hi Heinrich,
This patch is fine to me.
Thanks,
Yisen
在 2016/5/18 4:01, Heinrich Schuchardt 写道:
> In the statement
> assert(priv || priv->ae_handle);
> the right side of || is only evaluated if priv is null.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> index 3d746c8..834a50a 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> @@ -720,7 +720,7 @@ static int hns_set_pauseparam(struct net_device *net_dev,
> struct hnae_handle *h;
> struct hnae_ae_ops *ops;
>
> - assert(priv || priv->ae_handle);
> + assert(priv && priv->ae_handle);
>
> h = priv->ae_handle;
> ops = h->dev->ops;
> @@ -780,7 +780,7 @@ static int hns_set_coalesce(struct net_device *net_dev,
> struct hnae_ae_ops *ops;
> int ret;
>
> - assert(priv || priv->ae_handle);
> + assert(priv && priv->ae_handle);
>
> ops = priv->ae_handle->dev->ops;
>
> @@ -1111,7 +1111,7 @@ void hns_get_regs(struct net_device *net_dev, struct ethtool_regs *cmd,
> struct hns_nic_priv *priv = netdev_priv(net_dev);
> struct hnae_ae_ops *ops;
>
> - assert(priv || priv->ae_handle);
> + assert(priv && priv->ae_handle);
>
> ops = priv->ae_handle->dev->ops;
>
> @@ -1135,7 +1135,7 @@ static int hns_get_regs_len(struct net_device *net_dev)
> struct hns_nic_priv *priv = netdev_priv(net_dev);
> struct hnae_ae_ops *ops;
>
> - assert(priv || priv->ae_handle);
> + assert(priv && priv->ae_handle);
>
> ops = priv->ae_handle->dev->ops;
> if (!ops->get_regs_len) {
>
[toc] | [prev] | [next] | [standalone]
| From | David Laight <David.Laight@ACULAB.COM> |
|---|---|
| Date | 2016-05-19 13:20 +0200 |
| Message-ID | <rAu9H-7pe-3@gated-at.bofh.it> |
| In reply to | #1402567 |
From: Heinrich Schuchardt > Sent: 17 May 2016 21:01 > In the statement > assert(priv || priv->ae_handle); > the right side of || is only evaluated if priv is null. > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> > --- > drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c > b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c > index 3d746c8..834a50a 100644 > --- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c > +++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c > @@ -720,7 +720,7 @@ static int hns_set_pauseparam(struct net_device *net_dev, > struct hnae_handle *h; > struct hnae_ae_ops *ops; > > - assert(priv || priv->ae_handle); > + assert(priv && priv->ae_handle); > > h = priv->ae_handle; > ops = h->dev->ops; ... Personally I'd just delete the assert(). It is probably easier to debug the 'oops' from the NULL pointer dereference that that of the assert(). If either value can be NULL (without a coding error) then you'd want to return an error. David
[toc] | [prev] | [next] | [standalone]
| From | Heinrich Schuchardt <xypron.glpk@gmx.de> |
|---|---|
| Date | 2016-05-19 21:30 +0200 |
| Subject | [PATCH v2 1/1] net: hns: avoid null pointer dereference |
| Message-ID | <rABNT-3Uc-3@gated-at.bofh.it> |
| In reply to | #1403647 |
In the statement
assert(priv || priv->ae_handle);
the right side of || is only evaluated if priv is null.
v2:
As suggested by David Leight and David Miller the assert
statements are removed.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
index 3d746c8..67a648c 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
@@ -46,7 +46,6 @@ static u32 hns_nic_get_link(struct net_device *net_dev)
u32 link_stat = priv->link;
struct hnae_handle *h;
- assert(priv && priv->ae_handle);
h = priv->ae_handle;
if (priv->phy) {
@@ -646,8 +645,6 @@ static void hns_nic_get_drvinfo(struct net_device *net_dev,
{
struct hns_nic_priv *priv = netdev_priv(net_dev);
- assert(priv);
-
strncpy(drvinfo->version, HNAE_DRIVER_VERSION,
sizeof(drvinfo->version));
drvinfo->version[sizeof(drvinfo->version) - 1] = '\0';
@@ -720,8 +717,6 @@ static int hns_set_pauseparam(struct net_device *net_dev,
struct hnae_handle *h;
struct hnae_ae_ops *ops;
- assert(priv || priv->ae_handle);
-
h = priv->ae_handle;
ops = h->dev->ops;
@@ -780,8 +775,6 @@ static int hns_set_coalesce(struct net_device *net_dev,
struct hnae_ae_ops *ops;
int ret;
- assert(priv || priv->ae_handle);
-
ops = priv->ae_handle->dev->ops;
if (ec->tx_coalesce_usecs != ec->rx_coalesce_usecs)
@@ -1111,8 +1104,6 @@ void hns_get_regs(struct net_device *net_dev, struct ethtool_regs *cmd,
struct hns_nic_priv *priv = netdev_priv(net_dev);
struct hnae_ae_ops *ops;
- assert(priv || priv->ae_handle);
-
ops = priv->ae_handle->dev->ops;
cmd->version = HNS_CHIP_VERSION;
@@ -1135,8 +1126,6 @@ static int hns_get_regs_len(struct net_device *net_dev)
struct hns_nic_priv *priv = netdev_priv(net_dev);
struct hnae_ae_ops *ops;
- assert(priv || priv->ae_handle);
-
ops = priv->ae_handle->dev->ops;
if (!ops->get_regs_len) {
netdev_err(net_dev, "ops->get_regs_len is null!\n");
--
2.1.4
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-05-23 23:00 +0200 |
| Subject | Re: [PATCH v2 1/1] net: hns: avoid null pointer dereference |
| Message-ID | <rC57d-2h8-35@gated-at.bofh.it> |
| In reply to | #1403934 |
From: Heinrich Schuchardt <xypron.glpk@gmx.de> Date: Thu, 19 May 2016 21:20:55 +0200 > In the statement > assert(priv || priv->ae_handle); > the right side of || is only evaluated if priv is null. > > v2: > As suggested by David Leight and David Miller the assert > statements are removed. > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Applied.
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-05-19 20:30 +0200 |
| Message-ID | <rAARP-3kP-3@gated-at.bofh.it> |
| In reply to | #1402567 |
From: Heinrich Schuchardt <xypron.glpk@gmx.de> Date: Tue, 17 May 2016 22:01:15 +0200 > In the statement > assert(priv || priv->ae_handle); > the right side of || is only evaluated if priv is null. > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> I agree with others that this assert() is pretty useless and should simply be removed.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web