Commit 8da07a39 authored by xypron.glpk@gmx.de's avatar xypron.glpk@gmx.de Committed by David S. Miller

net: hns: avoid null pointer dereference

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: default avatarHeinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c685293a
...@@ -46,7 +46,6 @@ static u32 hns_nic_get_link(struct net_device *net_dev) ...@@ -46,7 +46,6 @@ static u32 hns_nic_get_link(struct net_device *net_dev)
u32 link_stat = priv->link; u32 link_stat = priv->link;
struct hnae_handle *h; struct hnae_handle *h;
assert(priv && priv->ae_handle);
h = priv->ae_handle; h = priv->ae_handle;
if (priv->phy) { if (priv->phy) {
...@@ -646,8 +645,6 @@ static void hns_nic_get_drvinfo(struct net_device *net_dev, ...@@ -646,8 +645,6 @@ static void hns_nic_get_drvinfo(struct net_device *net_dev,
{ {
struct hns_nic_priv *priv = netdev_priv(net_dev); struct hns_nic_priv *priv = netdev_priv(net_dev);
assert(priv);
strncpy(drvinfo->version, HNAE_DRIVER_VERSION, strncpy(drvinfo->version, HNAE_DRIVER_VERSION,
sizeof(drvinfo->version)); sizeof(drvinfo->version));
drvinfo->version[sizeof(drvinfo->version) - 1] = '\0'; drvinfo->version[sizeof(drvinfo->version) - 1] = '\0';
...@@ -720,8 +717,6 @@ static int hns_set_pauseparam(struct net_device *net_dev, ...@@ -720,8 +717,6 @@ static int hns_set_pauseparam(struct net_device *net_dev,
struct hnae_handle *h; struct hnae_handle *h;
struct hnae_ae_ops *ops; struct hnae_ae_ops *ops;
assert(priv || priv->ae_handle);
h = priv->ae_handle; h = priv->ae_handle;
ops = h->dev->ops; ops = h->dev->ops;
...@@ -780,8 +775,6 @@ static int hns_set_coalesce(struct net_device *net_dev, ...@@ -780,8 +775,6 @@ static int hns_set_coalesce(struct net_device *net_dev,
struct hnae_ae_ops *ops; struct hnae_ae_ops *ops;
int ret; int ret;
assert(priv || priv->ae_handle);
ops = priv->ae_handle->dev->ops; ops = priv->ae_handle->dev->ops;
if (ec->tx_coalesce_usecs != ec->rx_coalesce_usecs) 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, ...@@ -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 hns_nic_priv *priv = netdev_priv(net_dev);
struct hnae_ae_ops *ops; struct hnae_ae_ops *ops;
assert(priv || priv->ae_handle);
ops = priv->ae_handle->dev->ops; ops = priv->ae_handle->dev->ops;
cmd->version = HNS_CHIP_VERSION; cmd->version = HNS_CHIP_VERSION;
...@@ -1135,8 +1126,6 @@ static int hns_get_regs_len(struct net_device *net_dev) ...@@ -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 hns_nic_priv *priv = netdev_priv(net_dev);
struct hnae_ae_ops *ops; struct hnae_ae_ops *ops;
assert(priv || priv->ae_handle);
ops = priv->ae_handle->dev->ops; ops = priv->ae_handle->dev->ops;
if (!ops->get_regs_len) { if (!ops->get_regs_len) {
netdev_err(net_dev, "ops->get_regs_len is null!\n"); netdev_err(net_dev, "ops->get_regs_len is null!\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment