[PATCH net-next] can: flexcan: flexcan_chip_start(): fix the error return code in flexcan_setup_stop_mode()

2018-12-03 Thread Wei Yongjun
The error return code PTR_ERR(gpr_np) is always 0 since gpr_np is
equal to NULL in this error handling case. Fix it by return -ENOENT.

Fixes: de3578c198c6 ("can: flexcan: add self wakeup support")
Signed-off-by: Wei Yongjun 
---
 drivers/net/can/flexcan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 0f36eaf..f412d84 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -1432,7 +1432,7 @@ static int flexcan_setup_stop_mode(struct platform_device 
*pdev)
gpr_np = of_find_node_by_phandle(phandle);
if (!gpr_np) {
dev_dbg(>dev, "could not find gpr node by phandle\n");
-   return PTR_ERR(gpr_np);
+   return -ENOENT;
}
 
priv = netdev_priv(dev);





[PATCH] xfrm: Fix error return code in xfrm_output_one()

2018-10-27 Thread Wei Yongjun
xfrm_output_one() does not return a error code when there is
no dst_entry attached to the skb, it is still possible crash
with a NULL pointer dereference in xfrm_output_resume(). Fix
it by return error code -EHOSTUNREACH.

Fixes: 9e1437937807 ("xfrm: Fix NULL pointer dereference when skb_dst_force 
clears the dst_entry.")
Signed-off-by: Wei Yongjun 
---
 net/xfrm/xfrm_output.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
index 4ae87c5c..fef6b2d 100644
--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -102,6 +102,7 @@ static int xfrm_output_one(struct sk_buff *skb, int err)
skb_dst_force(skb);
if (!skb_dst(skb)) {
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
+   err = -EHOSTUNREACH;
goto error_nolock;
}





[PATCH] octeontx2-af: Use GFP_ATOMIC under spin lock

2018-10-24 Thread Wei Yongjun
The function nix_update_mce_list() is called from
nix_update_bcast_mce_list(), and a spin lock is held
here, so we should use GFP_ATOMIC instead.

Fixes: 4b05528ebf0c ("octeontx2-af: Update bcast list upon NIXLF alloc/free")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 8890c95..a618e48 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -1294,7 +1294,7 @@ static int nix_update_mce_list(struct nix_mce_list 
*mce_list,
return 0;
 
/* Add a new one to the list, at the tail */
-   mce = kzalloc(sizeof(*mce), GFP_KERNEL);
+   mce = kzalloc(sizeof(*mce), GFP_ATOMIC);
if (!mce)
return -ENOMEM;
mce->idx = idx;



[PATCH -next] fore200e: fix missing unlock on error in bsq_audit()

2018-10-14 Thread Wei Yongjun
Add the missing unlock before return from function bsq_audit()
in the error handling case.

Fixes: 1d9d8be91788 ("fore200e: check for dma mapping failures")
Signed-off-by: Wei Yongjun 
---
 drivers/atm/fore200e.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index 2b5dc8f..ffc07ab 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -1606,6 +1606,7 @@ int bsq_audit(int where, struct host_bsq* bsq, int 
scheme, int magn)
 if (dma_mapping_error(fore200e->dev, tpd->tsd[0].buffer)) {
if (tx_copy)
kfree(data);
+   spin_unlock_irqrestore(>q_lock, flags);
return -ENOMEM;
 }
 tpd->tsd[ 0 ].length = tx_len;



[PATCH net-next] net: sched: make function qdisc_free_cb() static

2018-09-27 Thread Wei Yongjun
Fixes the following sparse warning:

net/sched/sch_generic.c:944:6: warning:
 symbol 'qdisc_free_cb' was not declared. Should it be static?

Fixes: 3a7d0d07a386 ("net: sched: extend Qdisc with rcu")
Signed-off-by: Wei Yongjun 
---
 net/sched/sch_generic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 531fac1..3023929 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -941,7 +941,7 @@ void qdisc_free(struct Qdisc *qdisc)
kfree((char *) qdisc - qdisc->padded);
 }
 
-void qdisc_free_cb(struct rcu_head *head)
+static void qdisc_free_cb(struct rcu_head *head)
 {
struct Qdisc *q = container_of(head, struct Qdisc, rcu);



[PATCH net-next] net: aquantia: Make function aq_fw1x_set_power() static

2018-09-26 Thread Wei Yongjun
Fixes the following sparse warning:

drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c:873:5: warning:
 symbol 'aq_fw1x_set_power' was not declared. Should it be static?

Fixes: a0da96c08cfa ("net: aquantia: implement WOL support")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c 
b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
index 0dd59b09..7def1cb 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
@@ -870,8 +870,8 @@ static int aq_fw1x_set_wol(struct aq_hw_s *self, bool 
wol_enabled, u8 *mac)
return err;
 }
 
-int aq_fw1x_set_power(struct aq_hw_s *self, unsigned int power_state,
- u8 *mac)
+static int aq_fw1x_set_power(struct aq_hw_s *self, unsigned int power_state,
+u8 *mac)
 {
struct hw_atl_utils_fw_rpc *prpc = NULL;
unsigned int rpc_size = 0U;



[PATCH net-next] net/tls: Make function get_rec() static

2018-09-26 Thread Wei Yongjun
Fixes the following sparse warning:

net/tls/tls_sw.c:655:16: warning:
 symbol 'get_rec' was not declared. Should it be static?

Fixes: a42055e8d2c3 ("net/tls: Add support for async encryption of records for 
performance")
Signed-off-by: Wei Yongjun 
---
 net/tls/tls_sw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index bcb24c4..207e3ca 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -652,7 +652,7 @@ static int memcopy_from_iter(struct sock *sk, struct 
iov_iter *from,
return rc;
 }
 
-struct tls_rec *get_rec(struct sock *sk)
+static struct tls_rec *get_rec(struct sock *sk)
 {
struct tls_context *tls_ctx = tls_get_ctx(sk);
struct tls_sw_context_tx *ctx = tls_sw_ctx_tx(tls_ctx);



[PATCH net-next] net/core: make function ___gnet_stats_copy_basic() static

2018-09-26 Thread Wei Yongjun
Fixes the following sparse warning:

net/core/gen_stats.c:166:1: warning:
 symbol '___gnet_stats_copy_basic' was not declared. Should it be static?

Fixes: 5e111210a443 ("net/core: Add new basic hardware counter")
Signed-off-by: Wei Yongjun 
---
 net/core/gen_stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
index 65a2e82..9bf1b9a 100644
--- a/net/core/gen_stats.c
+++ b/net/core/gen_stats.c
@@ -162,7 +162,7 @@
 }
 EXPORT_SYMBOL(__gnet_stats_copy_basic);
 
-int
+static int
 ___gnet_stats_copy_basic(const seqcount_t *running,
 struct gnet_dump *d,
 struct gnet_stats_basic_cpu __percpu *cpu,



[PATCH RESEND] PCI: hv: Fix return value check in hv_pci_assign_slots()

2018-09-20 Thread Wei Yongjun
In case of error, the function pci_create_slot() returns ERR_PTR() and
never returns NULL. The NULL test in the return value check should be
replaced with IS_ERR().

Fixes: a15f2c08c708 ("PCI: hv: support reporting serial number as slot 
information")
Signed-off-by: Wei Yongjun 
---
Since the orig patch is merged from net tree, cc netdev@vger.kernel.org
---
 drivers/pci/controller/pci-hyperv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/pci-hyperv.c 
b/drivers/pci/controller/pci-hyperv.c
index ee80e79..9ba4d12 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -1484,8 +1484,10 @@ static void hv_pci_assign_slots(struct hv_pcibus_device 
*hbus)
snprintf(name, SLOT_NAME_SIZE, "%u", hpdev->desc.ser);
hpdev->pci_slot = pci_create_slot(hbus->pci_bus, slot_nr,
  name, NULL);
-   if (!hpdev->pci_slot)
+   if (IS_ERR(hpdev->pci_slot)) {
pr_warn("pci_create slot %s failed\n", name);
+   hpdev->pci_slot = NULL;
+   }
}
 }



[PATCH net-next] net: hns: make function hns_gmac_wait_fifo_clean() static

2018-09-14 Thread Wei Yongjun
Fixes the following sparse warning:

drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c:322:5: warning:
 symbol 'hns_gmac_wait_fifo_clean' was not declared. Should it be static?

Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
index 09e4061..aaf72c0 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
@@ -319,7 +319,7 @@ static void hns_gmac_set_promisc(void *mac_drv, u8 en)
hns_gmac_set_uc_match(mac_drv, en);
 }
 
-int hns_gmac_wait_fifo_clean(void *mac_drv)
+static int hns_gmac_wait_fifo_clean(void *mac_drv)
 {
struct mac_driver *drv = (struct mac_driver *)mac_drv;
int wait_cnt;



[PATCH net-next] net: lantiq: Fix return value check in xrx200_probe()

2018-09-14 Thread Wei Yongjun
In case of error, the function devm_ioremap_resource() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().

Fixes: fe1a56420cf2 ("net: lantiq: Add Lantiq / Intel VRX200 Ethernet driver")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/lantiq_xrx200.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/lantiq_xrx200.c 
b/drivers/net/ethernet/lantiq_xrx200.c
index c8b6d90..4a16076 100644
--- a/drivers/net/ethernet/lantiq_xrx200.c
+++ b/drivers/net/ethernet/lantiq_xrx200.c
@@ -461,9 +461,9 @@ static int xrx200_probe(struct platform_device *pdev)
}
 
priv->pmac_reg = devm_ioremap_resource(dev, res);
-   if (!priv->pmac_reg) {
+   if (IS_ERR(priv->pmac_reg)) {
dev_err(dev, "failed to request and remap io ranges\n");
-   return -ENOMEM;
+   return PTR_ERR(priv->pmac_reg);
}
 
priv->chan_rx.dma.irq = platform_get_irq_byname(pdev, "rx");



[PATCH net-next] net: dsa: gswip: Fix copy-paste error in gswip_gphy_fw_probe()

2018-09-14 Thread Wei Yongjun
The return value from of_reset_control_array_get_exclusive() is not
checked correctly. The test is done against a wrong variable. This
patch fix it.

Fixes: 14fceff4771e ("net: dsa: Add Lantiq / Intel DSA driver for vrx200")
Signed-off-by: Wei Yongjun 
---
 drivers/net/dsa/lantiq_gswip.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index 9c28d0b..9c10570 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -934,10 +934,10 @@ static int gswip_gphy_fw_probe(struct gswip_priv *priv,
}
 
gphy_fw->reset = of_reset_control_array_get_exclusive(gphy_fw_np);
-   if (IS_ERR(priv->gphy_fw)) {
-   if (PTR_ERR(priv->gphy_fw) != -EPROBE_DEFER)
+   if (IS_ERR(gphy_fw->reset)) {
+   if (PTR_ERR(gphy_fw->reset) != -EPROBE_DEFER)
dev_err(dev, "Failed to lookup gphy reset\n");
-   return PTR_ERR(priv->gphy_fw);
+   return PTR_ERR(gphy_fw->reset);
}
 
return gswip_gphy_fw_load(priv, gphy_fw);



[PATCH net-next] net: dsa: gswip: Fix return value check in gswip_probe()

2018-09-14 Thread Wei Yongjun
In case of error, the function devm_ioremap_resource() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().

Fixes: 14fceff4771e ("net: dsa: Add Lantiq / Intel DSA driver for vrx200")
Signed-off-by: Wei Yongjun 
---
 drivers/net/dsa/lantiq_gswip.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index 9c28d0b..faac359 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -1044,18 +1044,18 @@ static int gswip_probe(struct platform_device *pdev)
 
gswip_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
priv->gswip = devm_ioremap_resource(dev, gswip_res);
-   if (!priv->gswip)
-   return -ENOMEM;
+   if (IS_ERR(priv->gswip))
+   return PTR_ERR(priv->gswip);
 
mdio_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
priv->mdio = devm_ioremap_resource(dev, mdio_res);
-   if (!priv->mdio)
-   return -ENOMEM;
+   if (IS_ERR(priv->mdio))
+   return PTR_ERR(priv->mdio);
 
mii_res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
priv->mii = devm_ioremap_resource(dev, mii_res);
-   if (!priv->mii)
-   return -ENOMEM;
+   if (IS_ERR(priv->mii))
+   return PTR_ERR(priv->mii);
 
priv->hw_info = of_device_get_match_data(dev);
if (!priv->hw_info)



[PATCH net-next] net/mlx5e: Make function mlx5i_grp_sw_update_stats() static

2018-09-05 Thread Wei Yongjun
Fixes the following sparse warning:

drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c:119:6: warning:
 symbol 'mlx5i_grp_sw_update_stats' was not declared. Should it be static?

Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c 
b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
index 48886b3..3dd9f88 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c
@@ -116,7 +116,7 @@ static void mlx5i_cleanup(struct mlx5e_priv *priv)
/* Do nothing .. */
 }
 
-void mlx5i_grp_sw_update_stats(struct mlx5e_priv *priv)
+static void mlx5i_grp_sw_update_stats(struct mlx5e_priv *priv)
 {
struct mlx5e_sw_stats s = { 0 };
int i, j;



[PATCH net-next] ieee802154: hwsim: fix missing unlock on error in hwsim_add_one()

2018-08-07 Thread Wei Yongjun
Add the missing unlock before return from function hwsim_add_one()
in the error handling case.

Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ieee802154/mac802154_hwsim.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ieee802154/mac802154_hwsim.c 
b/drivers/net/ieee802154/mac802154_hwsim.c
index f4e9205..44d398c 100644
--- a/drivers/net/ieee802154/mac802154_hwsim.c
+++ b/drivers/net/ieee802154/mac802154_hwsim.c
@@ -810,8 +810,10 @@ static int hwsim_add_one(struct genl_info *info, struct 
device *dev,
mutex_lock(_phys_lock);
if (init) {
err = hwsim_subscribe_all_others(phy);
-   if (err < 0)
+   if (err < 0) {
+   mutex_unlock(_phys_lock);
goto err_reg;
+   }
}
list_add_tail(>list, _phys);
mutex_unlock(_phys_lock);



[PATCH net-next] ieee802154: hwsim: fix copy-paste error in hwsim_set_edge_lqi()

2018-08-07 Thread Wei Yongjun
The return value from kzalloc() is not checked correctly. The
test is done against a wrong variable. This patch fix it.

Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ieee802154/mac802154_hwsim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ieee802154/mac802154_hwsim.c 
b/drivers/net/ieee802154/mac802154_hwsim.c
index 1982308..04f4100 100644
--- a/drivers/net/ieee802154/mac802154_hwsim.c
+++ b/drivers/net/ieee802154/mac802154_hwsim.c
@@ -564,7 +564,7 @@ static int hwsim_set_edge_lqi(struct sk_buff *msg, struct 
genl_info *info)
}
 
einfo = kzalloc(sizeof(*einfo), GFP_KERNEL);
-   if (!info) {
+   if (!einfo) {
mutex_unlock(_phys_lock);
return -ENOMEM;
}



[PATCH net-next] rxrpc: Remove set but not used variable 'nowj'

2018-08-01 Thread Wei Yongjun
Fixes gcc '-Wunused-but-set-variable' warning:

net/rxrpc/proc.c: In function 'rxrpc_call_seq_show':
net/rxrpc/proc.c:66:29: warning:
 variable 'nowj' set but not used [-Wunused-but-set-variable]
  unsigned long timeout = 0, nowj;
 ^

Signed-off-by: Wei Yongjun 
---
 net/rxrpc/proc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/rxrpc/proc.c b/net/rxrpc/proc.c
index 163d05d..9805e3b 100644
--- a/net/rxrpc/proc.c
+++ b/net/rxrpc/proc.c
@@ -63,7 +63,7 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
struct rxrpc_peer *peer;
struct rxrpc_call *call;
struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
-   unsigned long timeout = 0, nowj;
+   unsigned long timeout = 0;
rxrpc_seq_t tx_hard_ack, rx_hard_ack;
char lbuff[50], rbuff[50];
 
@@ -97,7 +97,6 @@ static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
 
if (call->state != RXRPC_CALL_SERVER_PREALLOC) {
timeout = READ_ONCE(call->expect_rx_by);
-   nowj = jiffies;
timeout -= jiffies;
}



[PATCH net-next] tcp: remove set but not used variable 'skb_size'

2018-07-31 Thread Wei Yongjun
Fixes gcc '-Wunused-but-set-variable' warning:

net/ipv4/tcp_output.c: In function 'tcp_collapse_retrans':
net/ipv4/tcp_output.c:2700:6: warning:
 variable 'skb_size' set but not used [-Wunused-but-set-variable]
  int skb_size, next_skb_size;
  ^

Signed-off-by: Wei Yongjun 
---
 net/ipv4/tcp_output.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 490df62..731e6d4 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2697,9 +2697,8 @@ static bool tcp_collapse_retrans(struct sock *sk, struct 
sk_buff *skb)
 {
struct tcp_sock *tp = tcp_sk(sk);
struct sk_buff *next_skb = skb_rb_next(skb);
-   int skb_size, next_skb_size;
+   int next_skb_size;
 
-   skb_size = skb->len;
next_skb_size = next_skb->len;
 
BUG_ON(tcp_skb_pcount(skb) != 1 || tcp_skb_pcount(next_skb) != 1);



[PATCH net-next] xfrm: Make function xfrmi_get_link_net() static

2018-07-28 Thread Wei Yongjun
Fixes the following sparse warning:

net/xfrm/xfrm_interface.c:745:12: warning:
 symbol 'xfrmi_get_link_net' was not declared. Should it be static?

Fixes: f203b76d7809 ("xfrm: Add virtual xfrm interfaces")
Signed-off-by: Wei Yongjun 
---
 net/xfrm/xfrm_interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c
index 31acc6f..2c0a5c5 100644
--- a/net/xfrm/xfrm_interface.c
+++ b/net/xfrm/xfrm_interface.c
@@ -742,7 +742,7 @@ static int xfrmi_fill_info(struct sk_buff *skb, const 
struct net_device *dev)
return -EMSGSIZE;
 }
 
-struct net *xfrmi_get_link_net(const struct net_device *dev)
+static struct net *xfrmi_get_link_net(const struct net_device *dev)
 {
struct xfrm_if *xi = netdev_priv(dev);



[PATCH net-next] lan743x: Make symbol lan743x_pm_ops static

2018-07-25 Thread Wei Yongjun
Fixes the following sparse warning:

drivers/net/ethernet/microchip/lan743x_main.c:2944:25: warning:
 symbol 'lan743x_pm_ops' was not declared. Should it be static?

Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/microchip/lan743x_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/lan743x_main.c 
b/drivers/net/ethernet/microchip/lan743x_main.c
index cd41911..bb323f2 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -2941,7 +2941,7 @@ static int lan743x_pm_resume(struct device *dev)
return 0;
 }
 
-const struct dev_pm_ops lan743x_pm_ops = {
+static const struct dev_pm_ops lan743x_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(lan743x_pm_suspend, lan743x_pm_resume)
 };
 #endif /*CONFIG_PM */



[PATCH net-next] tcp: make function tcp_retransmit_stamp() static

2018-07-24 Thread Wei Yongjun
Fixes the following sparse warnings:

net/ipv4/tcp_timer.c:25:5: warning:
 symbol 'tcp_retransmit_stamp' was not declared. Should it be static?

Signed-off-by: Wei Yongjun 
---
 net/ipv4/tcp_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index a242f88..7fdf222 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -22,7 +22,7 @@
 #include 
 #include 
 
-u32 tcp_retransmit_stamp(const struct sock *sk)
+static u32 tcp_retransmit_stamp(const struct sock *sk)
 {
u32 start_ts = tcp_sk(sk)->retrans_stamp;



[PATCH net-next] net: igmp: make function __ip_mc_inc_group() static

2018-07-24 Thread Wei Yongjun
Fixes the following sparse warnings:

net/ipv4/igmp.c:1391:6: warning:
 symbol '__ip_mc_inc_group' was not declared. Should it be static?

Signed-off-by: Wei Yongjun 
---
 net/ipv4/igmp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 598333b..c9f8d46 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1388,7 +1388,8 @@ static void ip_mc_hash_remove(struct in_device *in_dev,
 /*
  * A socket has joined a multicast group on device dev.
  */
-void __ip_mc_inc_group(struct in_device *in_dev, __be32 addr, unsigned int 
mode)
+static void __ip_mc_inc_group(struct in_device *in_dev, __be32 addr,
+ unsigned int mode)
 {
struct ip_mc_list *im;
 #ifdef CONFIG_IP_MULTICAST



[PATCH net-next] net: aquantia: Make some functions static

2018-07-05 Thread Wei Yongjun
Fixes the following sparse warnings:

drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c:525:5: warning:
 symbol 'hw_atl_utils_mpi_set_speed' was not declared. Should it be static?
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c:536:5: warning:
 symbol 'hw_atl_utils_mpi_set_state' was not declared. Should it be static?

Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c 
b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
index e1feba5..c965e65 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
@@ -522,7 +522,7 @@ void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self,
 err_exit:;
 }
 
-int hw_atl_utils_mpi_set_speed(struct aq_hw_s *self, u32 speed)
+static int hw_atl_utils_mpi_set_speed(struct aq_hw_s *self, u32 speed)
 {
u32 val = aq_hw_read_reg(self, HW_ATL_MPI_CONTROL_ADR);
 
@@ -533,8 +533,8 @@ int hw_atl_utils_mpi_set_speed(struct aq_hw_s *self, u32 
speed)
return 0;
 }
 
-int hw_atl_utils_mpi_set_state(struct aq_hw_s *self,
-  enum hal_atl_utils_fw_state_e state)
+static int hw_atl_utils_mpi_set_state(struct aq_hw_s *self,
+ enum hal_atl_utils_fw_state_e state)
 {
int err = 0;
u32 transaction_id = 0;



[PATCH net-next] net: dsa: vsc73xx: Make some functions static

2018-07-05 Thread Wei Yongjun
Fixes the following sparse warnings:

drivers/net/dsa/vitesse-vsc73xx.c:1054:6: warning:
 symbol 'vsc73xx_get_strings' was not declared. Should it be static?
drivers/net/dsa/vitesse-vsc73xx.c:1113:5: warning:
 symbol 'vsc73xx_get_sset_count' was not declared. Should it be static?
drivers/net/dsa/vitesse-vsc73xx.c:1122:6: warning:
 symbol 'vsc73xx_get_ethtool_stats' was not declared. Should it be static?

Signed-off-by: Wei Yongjun 
---
 drivers/net/dsa/vitesse-vsc73xx.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/vitesse-vsc73xx.c 
b/drivers/net/dsa/vitesse-vsc73xx.c
index a4fc260..d4ea5cd 100644
--- a/drivers/net/dsa/vitesse-vsc73xx.c
+++ b/drivers/net/dsa/vitesse-vsc73xx.c
@@ -1051,8 +1051,8 @@ static void vsc73xx_port_disable(struct dsa_switch *ds, 
int port,
return NULL;
 }
 
-void vsc73xx_get_strings(struct dsa_switch *ds, int port, u32 stringset,
-uint8_t *data)
+static void vsc73xx_get_strings(struct dsa_switch *ds, int port, u32 stringset,
+   uint8_t *data)
 {
const struct vsc73xx_counter *cnt;
struct vsc73xx *vsc = ds->priv;
@@ -1110,7 +1110,7 @@ void vsc73xx_get_strings(struct dsa_switch *ds, int port, 
u32 stringset,
}
 }
 
-int vsc73xx_get_sset_count(struct dsa_switch *ds, int port, int sset)
+static int vsc73xx_get_sset_count(struct dsa_switch *ds, int port, int sset)
 {
/* We only support SS_STATS */
if (sset != ETH_SS_STATS)
@@ -1119,7 +1119,8 @@ int vsc73xx_get_sset_count(struct dsa_switch *ds, int 
port, int sset)
return 8;
 }
 
-void vsc73xx_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *data)
+static void vsc73xx_get_ethtool_stats(struct dsa_switch *ds, int port,
+ uint64_t *data)
 {
struct vsc73xx *vsc = ds->priv;
u8 regs[] = {



[PATCH net-next] net: sched: act_pedit: fix possible memory leak in tcf_pedit_init()

2018-07-03 Thread Wei Yongjun
'keys_ex' is malloced by tcf_pedit_keys_ex_parse() in tcf_pedit_init()
but not all of the error handle path free it, this may cause memory
leak. This patch fix it.

Fixes: 71d0ed7079df ("net/act_pedit: Support using offset relative to the 
conventional network headers")
Signed-off-by: Wei Yongjun 
---
 net/sched/act_pedit.c | 25 -
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
index 55bc96b..e43aef2 100644
--- a/net/sched/act_pedit.c
+++ b/net/sched/act_pedit.c
@@ -175,32 +175,35 @@ static int tcf_pedit_init(struct net *net, struct nlattr 
*nla,
if (!tcf_idr_check(tn, parm->index, a, bind)) {
if (!parm->nkeys) {
NL_SET_ERR_MSG_MOD(extack, "Pedit requires keys to be 
passed");
-   return -EINVAL;
+   ret = -EINVAL;
+   goto out_free;
}
ret = tcf_idr_create(tn, parm->index, est, a,
 _pedit_ops, bind, false);
if (ret)
-   return ret;
+   goto out_free;
p = to_pedit(*a);
keys = kmalloc(ksize, GFP_KERNEL);
if (!keys) {
tcf_idr_release(*a, bind);
-   kfree(keys_ex);
-   return -ENOMEM;
+   ret = -ENOMEM;
+   goto out_free;
}
ret = ACT_P_CREATED;
} else {
if (bind)
-   return 0;
+   goto out_free;
tcf_idr_release(*a, bind);
-   if (!ovr)
-   return -EEXIST;
+   if (!ovr) {
+   ret = -EEXIST;
+   goto out_free;
+   }
p = to_pedit(*a);
if (p->tcfp_nkeys && p->tcfp_nkeys != parm->nkeys) {
keys = kmalloc(ksize, GFP_KERNEL);
if (!keys) {
-   kfree(keys_ex);
-   return -ENOMEM;
+   ret = -ENOMEM;
+   goto out_free;
}
}
}
@@ -222,6 +225,10 @@ static int tcf_pedit_init(struct net *net, struct nlattr 
*nla,
if (ret == ACT_P_CREATED)
tcf_idr_insert(tn, *a);
return ret;
+out_free:
+   kfree(keys_ex);
+   return ret;
+
 }
 
 static void tcf_pedit_cleanup(struct tc_action *a)



[PATCH] hinic: reset irq affinity before freeing irq

2018-06-27 Thread Wei Yongjun
Following warning is seen when rmmod hinic. This is because affinity
value is not reset before calling free_irq(). This patch fixes it.

[   55.181232] WARNING: CPU: 38 PID: 19589 at kernel/irq/manage.c:1608
__free_irq+0x2aa/0x2c0

Fixes: 352f58b0d9f2 ("net-next/hinic: Set Rxq irq to specific cpu for NUMA")
Signed-off-by: Wei Yongjun 

diff --git a/drivers/net/ethernet/huawei/hinic/hinic_rx.c 
b/drivers/net/ethernet/huawei/hinic/hinic_rx.c
index e2e5cdc..4c0f7ed 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_rx.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_rx.c
@@ -439,6 +439,7 @@ static void rx_free_irq(struct hinic_rxq *rxq)
 {
struct hinic_rq *rq = rxq->rq;
 
+   irq_set_affinity_hint(rq->irq, NULL);
free_irq(rq->irq, rxq);
rx_del_napi(rxq);
 }



[PATCH net-next] net/mlx5e: fix error return code in mlx5e_alloc_rq()

2018-06-04 Thread Wei Yongjun
Fix to return error code -ENOMEM from the kvzalloc_node() error handling
case instead of 0, as done elsewhere in this function.

Fixes: 069d11465a80 ("net/mlx5e: RX, Enhance legacy Receive Queue memory 
scheme")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 333d4ed..89c96a0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -566,8 +566,10 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
kvzalloc_node((wq_sz << rq->wqe.info.log_num_frags) *
  sizeof(*rq->wqe.frags),
  GFP_KERNEL, cpu_to_node(c->cpu));
-   if (!rq->wqe.frags)
+   if (!rq->wqe.frags) {
+   err = -ENOMEM;
goto err_free;
+   }
 
err = mlx5e_init_di_list(rq, params, wq_sz, c->cpu);
if (err)



[PATCH net-next] net/mlx5e: Make function mlx5e_change_rep_mtu() static

2018-06-04 Thread Wei Yongjun
Fixes the following sparse warning:

drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:903:5: warning:
 symbol 'mlx5e_change_rep_mtu' was not declared. Should it be static?

Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 3857f22..57987f6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -900,7 +900,7 @@ int mlx5e_get_offload_stats(int attr_id, const struct 
net_device *dev,
.switchdev_port_attr_get= mlx5e_attr_get,
 };
 
-int mlx5e_change_rep_mtu(struct net_device *netdev, int new_mtu)
+static int mlx5e_change_rep_mtu(struct net_device *netdev, int new_mtu)
 {
return mlx5e_change_mtu(netdev, new_mtu, NULL);
 }



[PATCH net-next] net/smc: fix error return code in smc_setsockopt()

2018-05-30 Thread Wei Yongjun
Fix to return error code -EINVAL instead of 0 if optlen is invalid.

Fixes: 01d2f7e2cdd3 ("net/smc: sockopts TCP_NODELAY and TCP_CORK")
Signed-off-by: Wei Yongjun 
---
 net/smc/af_smc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 2c369d4..973b447 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -1420,7 +1420,7 @@ static int smc_setsockopt(struct socket *sock, int level, 
int optname,
return rc;
 
if (optlen < sizeof(int))
-   return rc;
+   return -EINVAL;
get_user(val, (int __user *)optval);
 
lock_sock(sk);



[PATCH net-next] net/mlx5: Make function mlx5_fpga_tls_send_teardown_cmd() static

2018-05-30 Thread Wei Yongjun
Fixes the following sparse warning:

drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c:199:6: warning:
 symbol 'mlx5_fpga_tls_send_teardown_cmd' was not declared. Should it be static?

Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c 
b/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c
index 2104801..c973623 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/tls.c
@@ -196,8 +196,8 @@ static void mlx5_fpga_tls_flow_to_cmd(void *flow, void *cmd)
 MLX5_GET(tls_flow, flow, direction_sx));
 }
 
-void mlx5_fpga_tls_send_teardown_cmd(struct mlx5_core_dev *mdev, void *flow,
-u32 swid, gfp_t flags)
+static void mlx5_fpga_tls_send_teardown_cmd(struct mlx5_core_dev *mdev,
+   void *flow, u32 swid, gfp_t flags)
 {
struct mlx5_teardown_stream_context *ctx;
struct mlx5_fpga_dma_buf *buf;



[PATCH net-next] hv_netvsc: fix error return code in netvsc_probe()

2018-05-30 Thread Wei Yongjun
Fix to return a negative error code from the failover register fail
error handling case instead of 0, as done elsewhere in this function.

Fixes: 1ff78076d8dd ("netvsc: refactor notifier/event handling code to use the 
failover framework")
Signed-off-by: Wei Yongjun 
---
 drivers/net/hyperv/netvsc_drv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index ebe9642..bef4d55 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -2031,8 +2031,10 @@ static int netvsc_probe(struct hv_device *dev,
}
 
net_device_ctx->failover = failover_register(net, _failover_ops);
-   if (IS_ERR(net_device_ctx->failover))
+   if (IS_ERR(net_device_ctx->failover)) {
+   ret = PTR_ERR(net_device_ctx->failover);
goto err_failover;
+   }
 
return ret;



[PATCH net-next] netfilter: nat: make symbol nat_hook static

2018-05-26 Thread Wei Yongjun
Fixes the following sparse warning:

net/netfilter/nf_nat_core.c:1039:20: warning:
 symbol 'nat_hook' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/netfilter/nf_nat_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index 821f8d8..b7df32a 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -1036,7 +1036,7 @@ void nf_nat_unregister_fn(struct net *net, const struct 
nf_hook_ops *ops,
.size = sizeof(struct nat_net),
 };
 
-struct nf_nat_hook nat_hook = {
+static struct nf_nat_hook nat_hook = {
.parse_nat_setup= nfnetlink_parse_nat_setup,
 #ifdef CONFIG_XFRM
.decode_session = __nf_nat_decode_session,



[PATCH net-next] net: bpfilter: make function bpfilter_mbox_request() static

2018-05-26 Thread Wei Yongjun
Fixes the following sparse warnings:

net/ipv4/bpfilter/sockopt.c:13:5: warning:
 symbol 'bpfilter_mbox_request' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/ipv4/bpfilter/sockopt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/bpfilter/sockopt.c b/net/ipv4/bpfilter/sockopt.c
index 42a96d2..5e04ed2 100644
--- a/net/ipv4/bpfilter/sockopt.c
+++ b/net/ipv4/bpfilter/sockopt.c
@@ -10,8 +10,9 @@
unsigned int optlen, bool is_set);
 EXPORT_SYMBOL_GPL(bpfilter_process_sockopt);
 
-int bpfilter_mbox_request(struct sock *sk, int optname, char __user *optval,
- unsigned int optlen, bool is_set)
+static int bpfilter_mbox_request(struct sock *sk, int optname,
+char __user *optval,
+unsigned int optlen, bool is_set)
 {
if (!bpfilter_process_sockopt) {
int err = request_module("bpfilter");



[PATCH net-next] vlan: vlan_hw_filter_capable() can be static

2018-03-31 Thread Wei Yongjun
Fixes the following sparse warning:

net/8021q/vlan_core.c:168:6: warning:
 symbol 'vlan_hw_filter_capable' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/8021q/vlan_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index c8d7abd..4f60e86 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -165,7 +165,7 @@ struct vlan_vid_info {
int refcount;
 };
 
-bool vlan_hw_filter_capable(const struct net_device *dev, __be16 proto)
+static bool vlan_hw_filter_capable(const struct net_device *dev, __be16 proto)
 {
if (proto == htons(ETH_P_8021Q) &&
dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)



[PATCH net-next V2] net: hns3: remove unnecessary pci_set_drvdata() and devm_kfree()

2018-03-29 Thread Wei Yongjun
There is no need for explicit calls of devm_kfree(), as the allocated
memory will be freed during driver's detach.

The driver core clears the driver data to NULL after device_release.
Thus, it is not needed to manually clear the device driver data to NULL.

So remove the unnecessary pci_set_drvdata() and devm_kfree().

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
v1 -> v2: change commit log
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index a31b4ad..8c55965 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1614,10 +1614,6 @@ static void hns3_remove(struct pci_dev *pdev)
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev);
 
hnae3_unregister_ae_dev(ae_dev);
-
-   devm_kfree(>dev, ae_dev);
-
-   pci_set_drvdata(pdev, NULL);
 }
 
 static struct pci_driver hns3_driver = {



[PATCH net-next] net: cavium: use module_pci_driver to simplify the code

2018-03-28 Thread Wei Yongjun
Use the module_pci_driver() macro to make the code simpler
by eliminating module_init and module_exit calls.

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/cavium/common/cavium_ptp.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/cavium/common/cavium_ptp.c 
b/drivers/net/ethernet/cavium/common/cavium_ptp.c
index d59497a..6aeb104 100644
--- a/drivers/net/ethernet/cavium/common/cavium_ptp.c
+++ b/drivers/net/ethernet/cavium/common/cavium_ptp.c
@@ -336,18 +336,7 @@ static void cavium_ptp_remove(struct pci_dev *pdev)
.remove = cavium_ptp_remove,
 };
 
-static int __init cavium_ptp_init_module(void)
-{
-   return pci_register_driver(_ptp_driver);
-}
-
-static void __exit cavium_ptp_cleanup_module(void)
-{
-   pci_unregister_driver(_ptp_driver);
-}
-
-module_init(cavium_ptp_init_module);
-module_exit(cavium_ptp_cleanup_module);
+module_pci_driver(cavium_ptp_driver);
 
 MODULE_DESCRIPTION(DRV_NAME);
 MODULE_AUTHOR("Cavium Networks <supp...@cavium.com>");



[PATCH net-next] cxgb4: fix error return code in adap_init0()

2018-03-28 Thread Wei Yongjun
Fix to return a negative error code from the hash filter init error
handling case instead of 0, as done elsewhere in this function.

Fixes: 5c31254e35a8 ("cxgb4: initialize hash-filter configuration")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 57d38f8..0072580 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4449,7 +4449,8 @@ static int adap_init0(struct adapter *adap)
adap->params.ofldq_wr_cred = val[5];
 
if (caps_cmd.niccaps & htons(FW_CAPS_CONFIG_NIC_HASHFILTER)) {
-   if (init_hash_filter(adap) < 0)
+   ret = init_hash_filter(adap);
+   if (ret < 0)
goto bye;
} else {
adap->params.offload = 1;



[PATCH net-next] net: bcmgenet: return NULL instead of plain integer

2018-03-28 Thread Wei Yongjun
Fixes the following sparse warning:

drivers/net/ethernet/broadcom/genet/bcmgenet.c:1351:16: warning:
 Using plain integer as NULL pointer

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c 
b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 7db8edc..2f4cb5c 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -1348,7 +1348,7 @@ static struct sk_buff *bcmgenet_free_tx_cb(struct device 
*dev,
dma_unmap_addr_set(cb, dma_addr, 0);
}
 
-   return 0;
+   return NULL;
 }
 
 /* Simple helper to free a receive control block's resources */



[PATCH net-next] net: hns3: remove unnecessary pci_set_drvdata() and devm_kfree()

2018-03-28 Thread Wei Yongjun
The devm_kfree function allocates memory that is released when a
driver detaches. Also the driver core clears the driver data to NULL
after device release. So remove the unnecessary pci_set_drvdata()
and devm_kfree().

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index a31b4ad..8c55965 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1614,10 +1614,6 @@ static void hns3_remove(struct pci_dev *pdev)
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev);
 
hnae3_unregister_ae_dev(ae_dev);
-
-   devm_kfree(>dev, ae_dev);
-
-   pci_set_drvdata(pdev, NULL);
 }
 
 static struct pci_driver hns3_driver = {



[PATCH net-next] ice: Fix error return code in ice_init_hw()

2018-03-28 Thread Wei Yongjun
Fix to return error code ICE_ERR_NO_MEMORY from the alloc error
handling case instead of 0, as done elsewhere in this function.

Fixes: dc49c7723676 ("ice: Get MAC/PHY/link info and scheduler topology")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/intel/ice/ice_common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_common.c 
b/drivers/net/ethernet/intel/ice/ice_common.c
index 385f5d4..21977ec 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -468,8 +468,10 @@ enum ice_status ice_init_hw(struct ice_hw *hw)
mac_buf_len = sizeof(struct ice_aqc_manage_mac_read_resp);
mac_buf = devm_kzalloc(ice_hw_to_dev(hw), mac_buf_len, GFP_KERNEL);
 
-   if (!mac_buf)
+   if (!mac_buf) {
+   status = ICE_ERR_NO_MEMORY;
goto err_unroll_fltr_mgmt_struct;
+   }
 
status = ice_aq_manage_mac_read(hw, mac_buf, mac_buf_len, NULL);
devm_kfree(ice_hw_to_dev(hw), mac_buf);



[PATCH net-next] tipc: tipc_node_create() can be static

2018-03-26 Thread Wei Yongjun
Fixes the following sparse warning:

net/tipc/node.c:336:18: warning:
 symbol 'tipc_node_create' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/tipc/node.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/tipc/node.c b/net/tipc/node.c
index 4a95c8c..4fb4327 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -333,8 +333,8 @@ static void tipc_node_write_unlock(struct tipc_node *n)
}
 }
 
-struct tipc_node *tipc_node_create(struct net *net, u32 addr,
-  u8 *peer_id, u16 capabilities)
+static struct tipc_node *tipc_node_create(struct net *net, u32 addr,
+ u8 *peer_id, u16 capabilities)
 {
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct tipc_node *n, *temp_node;



[PATCH net-next] tipc: fix error handling in tipc_udp_enable()

2018-03-26 Thread Wei Yongjun
Release alloced resource before return from the error handling
case in tipc_udp_enable(), otherwise will cause memory leak.

Fixes: 52dfae5c85a4 ("tipc: obtain node identity from interface by default")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/tipc/udp_media.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index 2c13b18..e7d91f5 100644
--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -687,7 +687,8 @@ static int tipc_udp_enable(struct net *net, struct 
tipc_bearer *b,
}
if (!tipc_own_id(net)) {
pr_warn("Failed to set node id, please configure manually\n");
-   return -EINVAL;
+   err = -EINVAL;
+   goto err;
}
 
b->bcast_addr.media_id = TIPC_MEDIA_TYPE_UDP;



[PATCH net-next] net: aquantia: Make function hw_atl_utils_mpi_set_speed() static

2018-03-26 Thread Wei Yongjun
Fixes the following sparse warning:

drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c:508:5: warning:
 symbol 'hw_atl_utils_mpi_set_speed' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c 
b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
index d3b847e..84d7f4d 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c
@@ -505,7 +505,7 @@ void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self,
 err_exit:;
 }
 
-int hw_atl_utils_mpi_set_speed(struct aq_hw_s *self, u32 speed)
+static int hw_atl_utils_mpi_set_speed(struct aq_hw_s *self, u32 speed)
 {
u32 val = aq_hw_read_reg(self, HW_ATL_MPI_CONTROL_ADR);



[PATCH net-next v2] sctp: fix error return code in sctp_sendmsg_new_asoc()

2018-03-12 Thread Wei Yongjun
Return error code -EINVAL in the address len check error handling
case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
in the for loop.

Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for 
sendmsg")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
Acked-by: Neil Horman <nhor...@tuxdriver.com>
---
v1 -> v2: remove the 'err' initialization
---
 net/sctp/socket.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 7d3476a..af5cf29 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1677,7 +1677,7 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 
sflags,
struct sctp_association *asoc;
enum sctp_scope scope;
struct cmsghdr *cmsg;
-   int err = -EINVAL;
+   int err;
 
*tp = NULL;
 
@@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 
sflags,
memset(daddr, 0, sizeof(*daddr));
dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
if (cmsg->cmsg_type == SCTP_DSTADDRV4) {
-   if (dlen < sizeof(struct in_addr))
+   if (dlen < sizeof(struct in_addr)) {
+   err = -EINVAL;
goto free;
+   }
 
dlen = sizeof(struct in_addr);
daddr->v4.sin_family = AF_INET;
daddr->v4.sin_port = htons(asoc->peer.port);
memcpy(>v4.sin_addr, CMSG_DATA(cmsg), dlen);
} else {
-   if (dlen < sizeof(struct in6_addr))
+   if (dlen < sizeof(struct in6_addr)) {
+   err = -EINVAL;
goto free;
+   }
 
dlen = sizeof(struct in6_addr);
daddr->v6.sin6_family = AF_INET6;



[PATCH net-next] mlxsw: spectrum_kvdl: Make some functions static

2018-03-12 Thread Wei Yongjun
Fixes the following sparse warnings:

drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c:371:5: warning:
 symbol 'mlxsw_sp_kvdl_single_occ_get' was not declared. Should it be static?
drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c:384:5: warning:
 symbol 'mlxsw_sp_kvdl_chunks_occ_get' was not declared. Should it be static?
drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c:397:5: warning:
 symbol 'mlxsw_sp_kvdl_large_chunks_occ_get' was not declared. Should it be 
static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
index 059eb32..4c9bff2 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
@@ -368,7 +368,7 @@ u64 mlxsw_sp_kvdl_occ_get(const struct mlxsw_sp *mlxsw_sp)
return occ;
 }
 
-u64 mlxsw_sp_kvdl_single_occ_get(struct devlink *devlink)
+static u64 mlxsw_sp_kvdl_single_occ_get(struct devlink *devlink)
 {
struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core);
@@ -381,7 +381,7 @@ u64 mlxsw_sp_kvdl_single_occ_get(struct devlink *devlink)
return mlxsw_sp_kvdl_part_occ(part);
 }
 
-u64 mlxsw_sp_kvdl_chunks_occ_get(struct devlink *devlink)
+static u64 mlxsw_sp_kvdl_chunks_occ_get(struct devlink *devlink)
 {
struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core);
@@ -394,7 +394,7 @@ u64 mlxsw_sp_kvdl_chunks_occ_get(struct devlink *devlink)
return mlxsw_sp_kvdl_part_occ(part);
 }
 
-u64 mlxsw_sp_kvdl_large_chunks_occ_get(struct devlink *devlink)
+static u64 mlxsw_sp_kvdl_large_chunks_occ_get(struct devlink *devlink)
 {
struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
struct mlxsw_sp *mlxsw_sp = mlxsw_core_driver_priv(mlxsw_core);



[PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()

2018-03-12 Thread Wei Yongjun
Return error code -EINVAL in the address len check error handling
case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
in the for loop.

Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for 
sendmsg")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/sctp/socket.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 7d3476a..5e7bfc2 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 
sflags,
memset(daddr, 0, sizeof(*daddr));
dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
if (cmsg->cmsg_type == SCTP_DSTADDRV4) {
-   if (dlen < sizeof(struct in_addr))
+   if (dlen < sizeof(struct in_addr)) {
+   err = -EINVAL;
goto free;
+   }
 
dlen = sizeof(struct in_addr);
daddr->v4.sin_family = AF_INET;
daddr->v4.sin_port = htons(asoc->peer.port);
memcpy(>v4.sin_addr, CMSG_DATA(cmsg), dlen);
} else {
-   if (dlen < sizeof(struct in6_addr))
+   if (dlen < sizeof(struct in6_addr)) {
+   err = -EINVAL;
goto free;
+   }
 
dlen = sizeof(struct in6_addr);
daddr->v6.sin6_family = AF_INET6;



[PATCH net-next] cxgb4: make symbol pedits static

2018-01-23 Thread Wei Yongjun
Fixes the following sparse warning:

drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c:46:27: warning:
 symbol 'pedits' was not declared. Should it be static?

Fixes: 27ece1f357b7 ("cxgb4: add tc flower support for ETH-DMAC rewrite")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
index 4fee355..3656336 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
@@ -43,7 +43,7 @@
 
 #define STATS_CHECK_PERIOD (HZ / 2)
 
-struct ch_tc_pedit_fields pedits[] = {
+static struct ch_tc_pedit_fields pedits[] = {
PEDIT_FIELDS(ETH_, DMAC_31_0, 4, dmac, 0),
PEDIT_FIELDS(ETH_, DMAC_47_32, 2, dmac, 4),
PEDIT_FIELDS(ETH_, SMAC_15_0, 2, smac, 0),



[PATCH net-next] nfp: fix error return code in nfp_pci_probe()

2018-01-22 Thread Wei Yongjun
Fix to return error code -EINVAL instead of 0 when num_vfs above
limit_vfs, as done elsewhere in this function.

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/netronome/nfp/nfp_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c 
b/drivers/net/ethernet/netronome/nfp/nfp_main.c
index c5b9104..cc570bb 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_main.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c
@@ -518,6 +518,7 @@ static int nfp_pci_probe(struct pci_dev *pdev,
dev_err(>dev,
"Error: %d VFs already enabled, but loaded FW can only 
support %d\n",
pf->num_vfs, pf->limit_vfs);
+   err = -EINVAL;
goto err_fw_unload;
}



[PATCH net-next] net: aquantia: make symbol hw_atl_boards static

2018-01-22 Thread Wei Yongjun
Fixes the following sparse warning:

drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c:50:34: warning:
 symbol 'hw_atl_boards' was not declared. Should it be static?

Fixes: 4948293ff963 ("net: aquantia: Introduce new AQC devices and 
capabilities")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c 
b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
index f5dd5f7..51a1a90 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
@@ -47,7 +47,7 @@
{}
 };
 
-const struct aq_board_revision_s hw_atl_boards[] = {
+static const struct aq_board_revision_s hw_atl_boards[] = {
{ AQ_DEVICE_ID_0001,AQ_HWREV_1, _atl_ops_a0, 
_atl_a0_caps_aqc107, },
{ AQ_DEVICE_ID_D100,AQ_HWREV_1, _atl_ops_a0, 
_atl_a0_caps_aqc100, },
{ AQ_DEVICE_ID_D107,AQ_HWREV_1, _atl_ops_a0, 
_atl_a0_caps_aqc107, },



[PATCH net-next] net: aquantia: Fix error return code in aq_pci_probe()

2018-01-22 Thread Wei Yongjun
Fix to return error code -ENOMEM from the aq_ndev_alloc() error
handling case instead of 0, as done elsewhere in this function.

Fixes: 23ee07ad3c2f ("net: aquantia: Cleanup pci functions module")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c 
b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
index f5dd5f7..5cf3542 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
@@ -210,8 +210,10 @@ static int aq_pci_probe(struct pci_dev *pdev,
goto err_pci_func;
 
ndev = aq_ndev_alloc();
-   if (!ndev)
+   if (!ndev) {
+   err = -ENOMEM;
goto err_ndev;
+   }
 
self = netdev_priv(ndev);
self->pdev = pdev;



[PATCH net-next] mlxsw: spectrum: Make function mlxsw_sp_kvdl_part_occ() static

2018-01-16 Thread Wei Yongjun
Fixes the following sparse warning:

drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c:289:5: warning:
 symbol 'mlxsw_sp_kvdl_part_occ' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
index cfacc17..55f9d2d 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_kvdl.c
@@ -286,7 +286,7 @@ static void mlxsw_sp_kvdl_parts_fini(struct mlxsw_sp 
*mlxsw_sp)
mlxsw_sp_kvdl_part_fini(mlxsw_sp, i);
 }
 
-u64 mlxsw_sp_kvdl_part_occ(struct mlxsw_sp_kvdl_part *part)
+static u64 mlxsw_sp_kvdl_part_occ(struct mlxsw_sp_kvdl_part *part)
 {
unsigned int nr_entries;
int bit = -1;



[PATCH net-next] devlink: Make some functions static

2018-01-16 Thread Wei Yongjun
Fixes the following sparse warnings:

net/core/devlink.c:2297:25: warning:
 symbol 'devlink_resource_find' was not declared. Should it be static?
net/core/devlink.c:2322:6: warning:
 symbol 'devlink_resource_validate_children' was not declared. Should it be 
static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/core/devlink.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index dd7d6dd..66d3670 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -2294,7 +2294,7 @@ static int devlink_nl_cmd_dpipe_table_counters_set(struct 
sk_buff *skb,
counters_enable);
 }
 
-struct devlink_resource *
+static struct devlink_resource *
 devlink_resource_find(struct devlink *devlink,
  struct devlink_resource *resource, u64 resource_id)
 {
@@ -2319,7 +2319,8 @@ struct devlink_resource *
return NULL;
 }
 
-void devlink_resource_validate_children(struct devlink_resource *resource)
+static void
+devlink_resource_validate_children(struct devlink_resource *resource)
 {
struct devlink_resource *child_resource;
bool size_valid = true;



[PATCH -next] bpf: cpumap: make some functions static

2018-01-16 Thread Wei Yongjun
Fixes the following sparse warnings:

kernel/bpf/cpumap.c:146:6: warning:
 symbol '__cpu_map_queue_destructor' was not declared. Should it be static?
kernel/bpf/cpumap.c:225:16: warning:
 symbol 'cpu_map_build_skb' was not declared. Should it be static?
kernel/bpf/cpumap.c:340:26: warning:
 symbol '__cpu_map_entry_alloc' was not declared. Should it be static?
kernel/bpf/cpumap.c:398:6: warning:
 symbol '__cpu_map_entry_free' was not declared. Should it be static?
kernel/bpf/cpumap.c:441:6: warning:
 symbol '__cpu_map_entry_replace' was not declared. Should it be static?
kernel/bpf/cpumap.c:454:5: warning:
 symbol 'cpu_map_delete_elem' was not declared. Should it be static?
kernel/bpf/cpumap.c:467:5: warning:
 symbol 'cpu_map_update_elem' was not declared. Should it be static?
kernel/bpf/cpumap.c:505:6: warning:
 symbol 'cpu_map_free' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 kernel/bpf/cpumap.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
index ce5b669..d392826 100644
--- a/kernel/bpf/cpumap.c
+++ b/kernel/bpf/cpumap.c
@@ -143,7 +143,7 @@ static struct bpf_map *cpu_map_alloc(union bpf_attr *attr)
return ERR_PTR(err);
 }
 
-void __cpu_map_queue_destructor(void *ptr)
+static void __cpu_map_queue_destructor(void *ptr)
 {
/* The tear-down procedure should have made sure that queue is
 * empty.  See __cpu_map_entry_replace() and work-queue
@@ -222,8 +222,8 @@ static struct xdp_pkt *convert_to_xdp_pkt(struct xdp_buff 
*xdp)
return xdp_pkt;
 }
 
-struct sk_buff *cpu_map_build_skb(struct bpf_cpu_map_entry *rcpu,
- struct xdp_pkt *xdp_pkt)
+static struct sk_buff *cpu_map_build_skb(struct bpf_cpu_map_entry *rcpu,
+struct xdp_pkt *xdp_pkt)
 {
unsigned int frame_size;
void *pkt_data_start;
@@ -337,7 +337,8 @@ static int cpu_map_kthread_run(void *data)
return 0;
 }
 
-struct bpf_cpu_map_entry *__cpu_map_entry_alloc(u32 qsize, u32 cpu, int map_id)
+static struct bpf_cpu_map_entry *__cpu_map_entry_alloc(u32 qsize, u32 cpu,
+  int map_id)
 {
gfp_t gfp = GFP_ATOMIC|__GFP_NOWARN;
struct bpf_cpu_map_entry *rcpu;
@@ -395,7 +396,7 @@ struct bpf_cpu_map_entry *__cpu_map_entry_alloc(u32 qsize, 
u32 cpu, int map_id)
return NULL;
 }
 
-void __cpu_map_entry_free(struct rcu_head *rcu)
+static void __cpu_map_entry_free(struct rcu_head *rcu)
 {
struct bpf_cpu_map_entry *rcpu;
int cpu;
@@ -438,8 +439,8 @@ void __cpu_map_entry_free(struct rcu_head *rcu)
  * cpu_map_kthread_stop, which waits for an RCU graze period before
  * stopping kthread, emptying the queue.
  */
-void __cpu_map_entry_replace(struct bpf_cpu_map *cmap,
-u32 key_cpu, struct bpf_cpu_map_entry *rcpu)
+static void __cpu_map_entry_replace(struct bpf_cpu_map *cmap,
+   u32 key_cpu, struct bpf_cpu_map_entry *rcpu)
 {
struct bpf_cpu_map_entry *old_rcpu;
 
@@ -451,7 +452,7 @@ void __cpu_map_entry_replace(struct bpf_cpu_map *cmap,
}
 }
 
-int cpu_map_delete_elem(struct bpf_map *map, void *key)
+static int cpu_map_delete_elem(struct bpf_map *map, void *key)
 {
struct bpf_cpu_map *cmap = container_of(map, struct bpf_cpu_map, map);
u32 key_cpu = *(u32 *)key;
@@ -464,8 +465,8 @@ int cpu_map_delete_elem(struct bpf_map *map, void *key)
return 0;
 }
 
-int cpu_map_update_elem(struct bpf_map *map, void *key, void *value,
-   u64 map_flags)
+static int cpu_map_update_elem(struct bpf_map *map, void *key, void *value,
+  u64 map_flags)
 {
struct bpf_cpu_map *cmap = container_of(map, struct bpf_cpu_map, map);
struct bpf_cpu_map_entry *rcpu;
@@ -502,7 +503,7 @@ int cpu_map_update_elem(struct bpf_map *map, void *key, 
void *value,
return 0;
 }
 
-void cpu_map_free(struct bpf_map *map)
+static void cpu_map_free(struct bpf_map *map)
 {
struct bpf_cpu_map *cmap = container_of(map, struct bpf_cpu_map, map);
int cpu;



[PATCH net-next] mlxsw: spectrum: qdiscs: Make function mlxsw_sp_qdisc_prio_unoffload static

2018-01-15 Thread Wei Yongjun
Fixes the following sparse warning:

drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c:464:1: warning:
 symbol 'mlxsw_sp_qdisc_prio_unoffload' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
index e11a0ab..fee9da8 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
@@ -460,7 +460,7 @@ int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port 
*mlxsw_sp_port,
return 0;
 }
 
-void
+static void
 mlxsw_sp_qdisc_prio_unoffload(struct mlxsw_sp_port *mlxsw_sp_port,
  struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
  void *params)



[PATCH net-next] i40evf: use GFP_ATOMIC under spin lock

2018-01-11 Thread Wei Yongjun
A spin lock is taken here so we should use GFP_ATOMIC.

Fixes: 504398f0a78e ("i40evf: use spinlock to protect (mac|vlan)_filter_list")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c 
b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
index feb95b6..ca5b538 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_virtchnl.c
@@ -459,7 +459,7 @@ void i40evf_add_ether_addrs(struct i40evf_adapter *adapter)
more = true;
}
 
-   veal = kzalloc(len, GFP_KERNEL);
+   veal = kzalloc(len, GFP_ATOMIC);
if (!veal) {
spin_unlock_bh(>mac_vlan_list_lock);
return;
@@ -532,7 +532,7 @@ void i40evf_del_ether_addrs(struct i40evf_adapter *adapter)
  (count * sizeof(struct virtchnl_ether_addr));
more = true;
}
-   veal = kzalloc(len, GFP_KERNEL);
+   veal = kzalloc(len, GFP_ATOMIC);
if (!veal) {
spin_unlock_bh(>mac_vlan_list_lock);
return;
@@ -606,7 +606,7 @@ void i40evf_add_vlans(struct i40evf_adapter *adapter)
  (count * sizeof(u16));
more = true;
}
-   vvfl = kzalloc(len, GFP_KERNEL);
+   vvfl = kzalloc(len, GFP_ATOMIC);
if (!vvfl) {
spin_unlock_bh(>mac_vlan_list_lock);
return;
@@ -678,7 +678,7 @@ void i40evf_del_vlans(struct i40evf_adapter *adapter)
  (count * sizeof(u16));
more = true;
}
-   vvfl = kzalloc(len, GFP_KERNEL);
+   vvfl = kzalloc(len, GFP_ATOMIC);
if (!vvfl) {
spin_unlock_bh(>mac_vlan_list_lock);
return;



[PATCH net-next] net: phy: mdio-bcm-unimac: fix potential NULL dereference in unimac_mdio_probe()

2018-01-11 Thread Wei Yongjun
platform_get_resource() may fail and return NULL, so we should
better check it's return value to avoid a NULL pointer dereference
a bit later in the code.

This is detected by Coccinelle semantic patch.

@@
expression pdev, res, n, t, e, e1, e2;
@@

res = platform_get_resource(pdev, t, n);
+ if (!res)
+   return -EINVAL;
... when != res == NULL
e = devm_ioremap(e1, res->start, e2);

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/phy/mdio-bcm-unimac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/phy/mdio-bcm-unimac.c 
b/drivers/net/phy/mdio-bcm-unimac.c
index 08e0647..8d37066 100644
--- a/drivers/net/phy/mdio-bcm-unimac.c
+++ b/drivers/net/phy/mdio-bcm-unimac.c
@@ -205,6 +205,8 @@ static int unimac_mdio_probe(struct platform_device *pdev)
return -ENOMEM;
 
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!r)
+   return -EINVAL;
 
/* Just ioremap, as this MDIO block is usually integrated into an
 * Ethernet MAC controller register range



[PATCH net-next] net: socionext: Fix error return code in netsec_netdev_open()

2018-01-11 Thread Wei Yongjun
Fix to return error code -ENODEV from the of_phy_connect() error
handling case instead of 0, as done elsewhere in this function.

Fixes: 533dd11a12f6 ("net: socionext: Add Synquacer NetSec driver")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/socionext/netsec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/socionext/netsec.c 
b/drivers/net/ethernet/socionext/netsec.c
index a8edcf3..78e4ff6 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -1292,6 +1292,7 @@ static int netsec_netdev_open(struct net_device *ndev)
netsec_phy_adjust_link, 0,
priv->phy_interface)) {
netif_err(priv, link, priv->ndev, "missing PHY\n");
+   ret = -ENODEV;
goto err3;
}
} else {



[PATCH net-next] netfilter: nf_flow_table: remove duplicated include from nf_flow_table_ipv6.c

2018-01-10 Thread Wei Yongjun
Remove duplicated include.

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/ipv6/netfilter/nf_flow_table_ipv6.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/ipv6/netfilter/nf_flow_table_ipv6.c 
b/net/ipv6/netfilter/nf_flow_table_ipv6.c
index 0c3b9d3..fff2160 100644
--- a/net/ipv6/netfilter/nf_flow_table_ipv6.c
+++ b/net/ipv6/netfilter/nf_flow_table_ipv6.c
@@ -5,7 +5,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 



[PATCH net-next] netfilter: nf_queue: remove duplicated include from nf_queue.c

2018-01-10 Thread Wei Yongjun
Remove duplicated include.

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/netfilter/nf_queue.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
index 7f55af5..d67a96a 100644
--- a/net/netfilter/nf_queue.c
+++ b/net/netfilter/nf_queue.c
@@ -15,8 +15,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 



[PATCH net-next] tcp: make local function tcp_recv_timestamp static

2018-01-09 Thread Wei Yongjun
Fixes the following sparse warning:

net/ipv4/tcp.c:1736:6: warning:
 symbol 'tcp_recv_timestamp' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/ipv4/tcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index f68cb33..d7cf861 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1733,8 +1733,8 @@ static void tcp_update_recv_tstamps(struct sk_buff *skb,
 }
 
 /* Similar to __sock_recv_timestamp, but does not require an skb */
-void tcp_recv_timestamp(struct msghdr *msg, const struct sock *sk,
-   struct scm_timestamping *tss)
+static void tcp_recv_timestamp(struct msghdr *msg, const struct sock *sk,
+  struct scm_timestamping *tss)
 {
struct timeval tv;
bool has_timestamping = false;



[PATCH net-next] net/mlx5e: fix error return code in mlx5e_alloc_rq()

2018-01-09 Thread Wei Yongjun
Fix to return a negative error code from the xdp_rxq_info_reg() error
handling case instead of 0, as done elsewhere in this function.

Fixes: 0ddf543226ac ("xdp/mlx5: setup xdp_rxq_info")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 539bd1d..6ba6671 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -582,7 +582,8 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
goto err_rq_wq_destroy;
}
 
-   if (xdp_rxq_info_reg(>xdp_rxq, rq->netdev, rq->ix) < 0)
+   err = xdp_rxq_info_reg(>xdp_rxq, rq->netdev, rq->ix);
+   if (err < 0)
goto err_rq_wq_destroy;
 
rq->buff.map_dir = rq->xdp_prog ? DMA_BIDIRECTIONAL : DMA_FROM_DEVICE;



[PATCH net-next] i40e: Make local function i40e_get_link_speed static

2018-01-09 Thread Wei Yongjun
Fixes the following sparse warning:

drivers/net/ethernet/intel/i40e/i40e_main.c:5440:5: warning:
 symbol 'i40e_get_link_speed' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c 
b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 42dcaef..0d4a7c69 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -5437,7 +5437,7 @@ static int i40e_vsi_config_tc(struct i40e_vsi *vsi, u8 
enabled_tc)
  * @vsi: VSI to be configured
  *
  **/
-int i40e_get_link_speed(struct i40e_vsi *vsi)
+static int i40e_get_link_speed(struct i40e_vsi *vsi)
 {
struct i40e_pf *pf = vsi->back;



[PATCH net-next] netfilter: core: make local function __nf_unregister_net_hook static

2018-01-09 Thread Wei Yongjun
Fixes the following sparse warning:

net/netfilter/core.c:380:6: warning:
 symbol '__nf_unregister_net_hook' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/netfilter/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index 997dd38..3f8e2d0 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -377,8 +377,8 @@ static void nf_remove_net_hook(struct nf_hook_entries *old,
}
 }
 
-void __nf_unregister_net_hook(struct net *net, int pf,
- const struct nf_hook_ops *reg)
+static void __nf_unregister_net_hook(struct net *net, int pf,
+const struct nf_hook_ops *reg)
 {
struct nf_hook_entries __rcu **pp;
struct nf_hook_entries *p;



[PATCH net-next] netfilter: nf_tables: fix a typo in nf_tables_getflowtable()

2018-01-09 Thread Wei Yongjun
Fix a typo, we should check 'flowtable' instead of 'table'.

Fixes: 3b49e2e94e6e ("netfilter: nf_tables: add flow table netlink frontend")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/netfilter/nf_tables_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 336b816..40594bb 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -5420,7 +5420,7 @@ static int nf_tables_getflowtable(struct net *net, struct 
sock *nlsk,
 
flowtable = nf_tables_flowtable_lookup(table, nla[NFTA_FLOWTABLE_NAME],
   genmask);
-   if (IS_ERR(table))
+   if (IS_ERR(flowtable))
return PTR_ERR(flowtable);
 
skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);



[PATCH net-next] net: dsa: lan9303: Fix error return code in lan9303_check_device()

2018-01-03 Thread Wei Yongjun
Fix to return error code -ENODEV from the chip not found error handling
case instead of 0(ret have been overwritten to 0 by lan9303_read()), as
done elsewhere in this function.

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/dsa/lan9303-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index 944901f..d4a5b45 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -867,7 +867,7 @@ static int lan9303_check_device(struct lan9303 *chip)
if ((reg >> 16) != LAN9303_CHIP_ID) {
dev_err(chip->dev, "expecting LAN9303 chip, but found: %X\n",
reg >> 16);
-   return ret;
+   return -ENODEV;
}
 
/* The default state of the LAN9303 device is to forward packets between



[PATCH net-next v3] net: sched: fix skb leak in dev_requeue_skb()

2017-12-27 Thread Wei Yongjun
When dev_requeue_skb() is called with bluked skb list, only the
first skb of the list will be requeued to qdisc layer, and leak
the others without free them.

TCP is broken due to skb leak since no free skb will be considered
as still in the host queue and never be retransmitted. This happend
when dev_requeue_skb() called from qdisc_restart().
  qdisc_restart
  |-- dequeue_skb
  |-- sch_direct_xmit()
  |-- dev_requeue_skb() <-- skb may bluked

Fix dev_requeue_skb() to requeue the full bluked list. Also change
to use __skb_queue_tail() in __dev_requeue_skb() to avoid skb out
of order.

Fixes: a53851e2c321 ("net: sched: explicit locking in gso_cpu fallback")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
v2 -> v3: move lock out of while loop
---
 net/sched/sch_generic.c | 29 +
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 10aaa3b6..1c149ed 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -111,10 +111,16 @@ static inline void qdisc_enqueue_skb_bad_txq(struct Qdisc 
*q,
 
 static inline int __dev_requeue_skb(struct sk_buff *skb, struct Qdisc *q)
 {
-   __skb_queue_head(>gso_skb, skb);
-   q->qstats.requeues++;
-   qdisc_qstats_backlog_inc(q, skb);
-   q->q.qlen++;/* it's still part of the queue */
+   while (skb) {
+   struct sk_buff *next = skb->next;
+
+   __skb_queue_tail(>gso_skb, skb);
+   q->qstats.requeues++;
+   qdisc_qstats_backlog_inc(q, skb);
+   q->q.qlen++;/* it's still part of the queue */
+
+   skb = next;
+   }
__netif_schedule(q);
 
return 0;
@@ -125,12 +131,19 @@ static inline int dev_requeue_skb_locked(struct sk_buff 
*skb, struct Qdisc *q)
spinlock_t *lock = qdisc_lock(q);
 
spin_lock(lock);
-   __skb_queue_tail(>gso_skb, skb);
+   while (skb) {
+   struct sk_buff *next = skb->next;
+
+   __skb_queue_tail(>gso_skb, skb);
+
+   qdisc_qstats_cpu_requeues_inc(q);
+   qdisc_qstats_cpu_backlog_inc(q, skb);
+   qdisc_qstats_cpu_qlen_inc(q);
+
+   skb = next;
+   }
spin_unlock(lock);
 
-   qdisc_qstats_cpu_requeues_inc(q);
-   qdisc_qstats_cpu_backlog_inc(q, skb);
-   qdisc_qstats_cpu_qlen_inc(q);
__netif_schedule(q);
 
return 0;
-- 
1.8.3.1



[PATCH net-next v2] net: sched: fix skb leak in dev_requeue_skb()

2017-12-24 Thread Wei Yongjun
When dev_requeue_skb() is called with bluked skb list, only the
first skb of the list will be requeued to qdisc layer, and leak
the others without free them.

TCP is broken due to skb leak since no free skb will be considered
as still in the host queue and never be retransmitted. This happend
when dev_requeue_skb() called from qdisc_restart().
  qdisc_restart
  |-- dequeue_skb
  |-- sch_direct_xmit()
  |-- dev_requeue_skb() <-- skb may bluked

Fix dev_requeue_skb() to requeue the full bluked list.

Fixes: a53851e2c321 ("net: sched: explicit locking in gso_cpu fallback")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
v1 -> v2: add net-next prefix
---
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 981c08f..0df2dbf 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -111,10 +111,16 @@ static inline void qdisc_enqueue_skb_bad_txq(struct Qdisc 
*q,
 
 static inline int __dev_requeue_skb(struct sk_buff *skb, struct Qdisc *q)
 {
-   __skb_queue_head(>gso_skb, skb);
-   q->qstats.requeues++;
-   qdisc_qstats_backlog_inc(q, skb);
-   q->q.qlen++;/* it's still part of the queue */
+   while (skb) {
+   struct sk_buff *next = skb->next;
+
+   __skb_queue_tail(>gso_skb, skb);
+   q->qstats.requeues++;
+   qdisc_qstats_backlog_inc(q, skb);
+   q->q.qlen++;/* it's still part of the queue */
+
+   skb = next;
+   }
__netif_schedule(q);
 
return 0;
@@ -124,13 +130,20 @@ static inline int dev_requeue_skb_locked(struct sk_buff 
*skb, struct Qdisc *q)
 {
spinlock_t *lock = qdisc_lock(q);
 
-   spin_lock(lock);
-   __skb_queue_tail(>gso_skb, skb);
-   spin_unlock(lock);
+   while (skb) {
+   struct sk_buff *next = skb->next;
+
+   spin_lock(lock);
+   __skb_queue_tail(>gso_skb, skb);
+   spin_unlock(lock);
+
+   qdisc_qstats_cpu_requeues_inc(q);
+   qdisc_qstats_cpu_backlog_inc(q, skb);
+   qdisc_qstats_cpu_qlen_inc(q);
+
+   skb = next;
+   }
 
-   qdisc_qstats_cpu_requeues_inc(q);
-   qdisc_qstats_cpu_backlog_inc(q, skb);
-   qdisc_qstats_cpu_qlen_inc(q);
__netif_schedule(q);
 
return 0;
-- 
1.8.3.1



[PATCH] net: sched: fix skb leak in dev_requeue_skb()

2017-12-24 Thread Wei Yongjun
When dev_requeue_skb() is called with bluked skb list, only the
first skb of the list will be requeued to qdisc layer, and leak
the others without free them.

TCP is broken due to skb leak since no free skb will be considered
as still in the host queue and never be retransmitted. This happend
when dev_requeue_skb() called from qdisc_restart().
  qdisc_restart
  |-- dequeue_skb
  |-- sch_direct_xmit()
  |-- dev_requeue_skb() <-- skb may bluked

Fix dev_requeue_skb() to requeue the full bluked list.

Fixes: a53851e2c321 ("net: sched: explicit locking in gso_cpu fallback")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>

diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 981c08f..0df2dbf 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -111,10 +111,16 @@ static inline void qdisc_enqueue_skb_bad_txq(struct Qdisc 
*q,
 
 static inline int __dev_requeue_skb(struct sk_buff *skb, struct Qdisc *q)
 {
-   __skb_queue_head(>gso_skb, skb);
-   q->qstats.requeues++;
-   qdisc_qstats_backlog_inc(q, skb);
-   q->q.qlen++;/* it's still part of the queue */
+   while (skb) {
+   struct sk_buff *next = skb->next;
+
+   __skb_queue_tail(>gso_skb, skb);
+   q->qstats.requeues++;
+   qdisc_qstats_backlog_inc(q, skb);
+   q->q.qlen++;/* it's still part of the queue */
+
+   skb = next;
+   }
__netif_schedule(q);
 
return 0;
@@ -124,13 +130,20 @@ static inline int dev_requeue_skb_locked(struct sk_buff 
*skb, struct Qdisc *q)
 {
spinlock_t *lock = qdisc_lock(q);
 
-   spin_lock(lock);
-   __skb_queue_tail(>gso_skb, skb);
-   spin_unlock(lock);
+   while (skb) {
+   struct sk_buff *next = skb->next;
+
+   spin_lock(lock);
+   __skb_queue_tail(>gso_skb, skb);
+   spin_unlock(lock);
+
+   qdisc_qstats_cpu_requeues_inc(q);
+   qdisc_qstats_cpu_backlog_inc(q, skb);
+   qdisc_qstats_cpu_qlen_inc(q);
+
+   skb = next;
+   }
 
-   qdisc_qstats_cpu_requeues_inc(q);
-   qdisc_qstats_cpu_backlog_inc(q, skb);
-   qdisc_qstats_cpu_qlen_inc(q);
__netif_schedule(q);
 
return 0;
-- 
1.8.3.1



[PATCH net-next] openvswitch: Using kfree_rcu() to simplify the code

2017-11-13 Thread Wei Yongjun
The callback function of call_rcu() just calls a kfree(), so we
can use kfree_rcu() instead of call_rcu() + callback function.

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/openvswitch/meter.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
index 2a5ba35..f9e2b1f 100644
--- a/net/openvswitch/meter.c
+++ b/net/openvswitch/meter.c
@@ -42,19 +42,12 @@
[OVS_BAND_ATTR_STATS] = { .len = sizeof(struct ovs_flow_stats) },
 };
 
-static void rcu_free_ovs_meter_callback(struct rcu_head *rcu)
-{
-   struct dp_meter *meter = container_of(rcu, struct dp_meter, rcu);
-
-   kfree(meter);
-}
-
 static void ovs_meter_free(struct dp_meter *meter)
 {
if (!meter)
return;
 
-   call_rcu(>rcu, rcu_free_ovs_meter_callback);
+   kfree_rcu(meter, rcu);
 }
 
 static struct hlist_head *meter_hash_bucket(const struct datapath *dp,



[PATCH net-next] openvswitch: Make local function ovs_nsh_key_attr_size() static

2017-11-13 Thread Wei Yongjun
Fixes the following sparse warnings:

net/openvswitch/flow_netlink.c:340:8: warning:
 symbol 'ovs_nsh_key_attr_size' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/openvswitch/flow_netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index 4201f92..d79c364 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -337,7 +337,7 @@ size_t ovs_tun_key_attr_size(void)
+ nla_total_size(4);   /* OVS_TUNNEL_KEY_ATTR_ERSPAN_OPTS */
 }
 
-size_t ovs_nsh_key_attr_size(void)
+static size_t ovs_nsh_key_attr_size(void)
 {
/* Whenever adding new OVS_NSH_KEY_ FIELDS, we should consider
 * updating this function.



[PATCH net-next] openvswitch: Fix return value check in ovs_meter_cmd_features()

2017-11-13 Thread Wei Yongjun
In case of error, the function ovs_meter_cmd_reply_start() returns
ERR_PTR() not NULL. The NULL test in the return value check should
be replaced with IS_ERR().

Fixes: 96fbc13d7e77 ("openvswitch: Add meter infrastructure")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/openvswitch/meter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
index 2a5ba35..2e58b6c 100644
--- a/net/openvswitch/meter.c
+++ b/net/openvswitch/meter.c
@@ -166,7 +166,7 @@ static int ovs_meter_cmd_features(struct sk_buff *skb, 
struct genl_info *info)
 
reply = ovs_meter_cmd_reply_start(info, OVS_METER_CMD_FEATURES,
  _reply_header);
-   if (!reply)
+   if (IS_ERR(reply))
return PTR_ERR(reply);
 
if (nla_put_u32(reply, OVS_METER_ATTR_MAX_METERS, U32_MAX) ||



[PATCH net-next] dpaa_eth: fix error return code in dpaa_eth_probe()

2017-11-06 Thread Wei Yongjun
Fix to return a negative error code from the dpaa_bp_alloc() error
handling case instead of 0, as done elsewhere in this function.

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index ebc55b6..6a05c6d 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -2728,11 +2728,11 @@ static int dpaa_eth_probe(struct platform_device *pdev)
 
/* bp init */
for (i = 0; i < DPAA_BPS_NUM; i++) {
-   int err;
-
dpaa_bps[i] = dpaa_bp_alloc(dev);
-   if (IS_ERR(dpaa_bps[i]))
+   if (IS_ERR(dpaa_bps[i])) {
+   err = PTR_ERR(dpaa_bps[i]);
goto free_dpaa_bps;
+   }
/* the raw size of the buffers used for reception */
dpaa_bps[i]->raw_size = bpool_buffer_raw_size(i, DPAA_BPS_NUM);
/* avoid runtime computations by keeping the usable size here */



[PATCH net-next] mlxsw: spectrum: Fix error return code in mlxsw_sp_port_create()

2017-11-06 Thread Wei Yongjun
Fix to return a negative error code from the VID  create error handling
case instead of 0, as done elsewhere in this function.

Fixes: c57529e1d5d8 ("mlxsw: spectrum: Replace vPorts with Port-VLAN")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 63e5087..6c604c6 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -3007,6 +3007,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp 
*mlxsw_sp, u8 local_port,
if (IS_ERR(mlxsw_sp_port_vlan)) {
dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to create VID 
1\n",
mlxsw_sp_port->local_port);
+   err = PTR_ERR(mlxsw_sp_port_vlan);
goto err_port_vlan_get;
}



[PATCH net-next] net/ncsi: Make local function ncsi_get_filter() static

2017-11-02 Thread Wei Yongjun
Fixes the following sparse warnings:

net/ncsi/ncsi-manage.c:41:5: warning:
 symbol 'ncsi_get_filter' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/ncsi/ncsi-manage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index 28c42b2..47baf91 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -38,7 +38,7 @@ static inline int ncsi_filter_size(int table)
return sizes[table];
 }
 
-u32 *ncsi_get_filter(struct ncsi_channel *nc, int table, int index)
+static u32 *ncsi_get_filter(struct ncsi_channel *nc, int table, int index)
 {
struct ncsi_channel_filter *ncf;
int size;



[PATCH net-next] cxgb4: fix error return code in cxgb4_set_hash_filter()

2017-11-02 Thread Wei Yongjun
Fix to return a negative error code from thecxgb4_alloc_atid()
error handling case instead of 0.

Fixes: 12b276fbf6e0 ("cxgb4: add support to create hash filters")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
index abab67d..5980f30 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
@@ -1110,8 +1110,10 @@ static int cxgb4_set_hash_filter(struct net_device *dev,
}
 
atid = cxgb4_alloc_atid(t, f);
-   if (atid < 0)
+   if (atid < 0) {
+   ret = atid;
goto free_smt;
+   }
 
iconf = adapter->params.tp.ingress_config;
if (iconf & VNIC_F) {



[PATCH net-next] phylink: make local function phylink_phy_change() static

2017-11-02 Thread Wei Yongjun
Fixes the following sparse warnings:

drivers/net/phy/phylink.c:570:6: warning:
 symbol 'phylink_phy_change' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/phy/phylink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 05c8f1c..e3bbc70 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -567,7 +567,8 @@ void phylink_destroy(struct phylink *pl)
 }
 EXPORT_SYMBOL_GPL(phylink_destroy);
 
-void phylink_phy_change(struct phy_device *phydev, bool up, bool do_carrier)
+static void phylink_phy_change(struct phy_device *phydev, bool up,
+  bool do_carrier)
 {
struct phylink *pl = phydev->phylink;
 





[PATCH net-next] sctp: fix error return code in sctp_send_add_streams()

2017-10-31 Thread Wei Yongjun
Fix to returnerror code -ENOMEM from the sctp_make_strreset_addstrm()
error handling case instead of 0. 'retval' can be overwritten to 0 after
call sctp_stream_alloc_out().

Fixes: e090abd0d81c ("sctp: factor out stream->out allocation")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/sctp/stream.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/sctp/stream.c b/net/sctp/stream.c
index 03764fc..b8c8cab 100644
--- a/net/sctp/stream.c
+++ b/net/sctp/stream.c
@@ -393,7 +393,7 @@ int sctp_send_add_streams(struct sctp_association *asoc,
 {
struct sctp_stream *stream = >stream;
struct sctp_chunk *chunk = NULL;
-   int retval = -ENOMEM;
+   int retval;
__u32 outcnt, incnt;
__u16 out, in;
 
@@ -425,8 +425,10 @@ int sctp_send_add_streams(struct sctp_association *asoc,
}
 
chunk = sctp_make_strreset_addstrm(asoc, out, in);
-   if (!chunk)
+   if (!chunk) {
+   retval = -ENOMEM;
goto out;
+   }
 
asoc->strreset_chunk = chunk;
sctp_chunk_hold(asoc->strreset_chunk);



[PATCH net-next] net: bcmgenet: Avoid calling platform_device_put() twice in bcmgenet_mii_exit()

2017-10-27 Thread Wei Yongjun
Remove platform_device_put() call after platform_device_unregister()
from function bcmgenet_mii_exit(), otherwise, we will call
platform_device_put() twice.

Fixes: 9a4e79697009 ("net: bcmgenet: utilize generic Broadcom UniMAC
MDIO controller driver")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/broadcom/genet/bcmmii.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c 
b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index ba3fcfd..5333274 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -571,5 +571,4 @@ void bcmgenet_mii_exit(struct net_device *dev)
of_phy_deregister_fixed_link(dn);
of_node_put(priv->phy_dn);
platform_device_unregister(priv->mii_pdev);
-   platform_device_put(priv->mii_pdev);
 }



[PATCH net-next] net: aquantia: Make local functions static

2017-10-27 Thread Wei Yongjun
Fixes the following sparse warnings:

drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c:224:5: warning:
 symbol 'aq_ethtool_get_coalesce' was not declared. Should it be static?
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c:245:5: warning:
 symbol 'aq_ethtool_set_coalesce' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c 
b/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c
index d5e99b4..70efb74 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c
@@ -221,8 +221,8 @@ static int aq_ethtool_get_rxnfc(struct net_device *ndev,
return err;
 }
 
-int aq_ethtool_get_coalesce(struct net_device *ndev,
-   struct ethtool_coalesce *coal)
+static int aq_ethtool_get_coalesce(struct net_device *ndev,
+  struct ethtool_coalesce *coal)
 {
struct aq_nic_s *aq_nic = netdev_priv(ndev);
struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(aq_nic);
@@ -242,8 +242,8 @@ int aq_ethtool_get_coalesce(struct net_device *ndev,
return 0;
 }
 
-int aq_ethtool_set_coalesce(struct net_device *ndev,
-   struct ethtool_coalesce *coal)
+static int aq_ethtool_set_coalesce(struct net_device *ndev,
+  struct ethtool_coalesce *coal)
 {
struct aq_nic_s *aq_nic = netdev_priv(ndev);
struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(aq_nic);



[PATCH net-next] net: hns3: make local functions static

2017-10-10 Thread Wei Yongjun
Fixes the following sparse warnings:

drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c:464:5: warning:
 symbol 'hns3_change_all_ring_bd_num' was not declared. Should it be static?
drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c:477:5: warning:
 symbol 'hns3_set_ringparam' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
index 9b36ce0..ddbd7f3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
@@ -461,7 +461,8 @@ static int hns3_get_rxnfc(struct net_device *netdev,
return 0;
 }
 
-int hns3_change_all_ring_bd_num(struct hns3_nic_priv *priv, u32 new_desc_num)
+static int hns3_change_all_ring_bd_num(struct hns3_nic_priv *priv,
+  u32 new_desc_num)
 {
struct hnae3_handle *h = priv->ae_handle;
int i;
@@ -474,7 +475,8 @@ int hns3_change_all_ring_bd_num(struct hns3_nic_priv *priv, 
u32 new_desc_num)
return hns3_init_all_ring(priv);
 }
 
-int hns3_set_ringparam(struct net_device *ndev, struct ethtool_ringparam 
*param)
+static int hns3_set_ringparam(struct net_device *ndev,
+ struct ethtool_ringparam *param)
 {
struct hns3_nic_priv *priv = netdev_priv(ndev);
struct hnae3_handle *h = priv->ae_handle;



[PATCH net-next] xfrm: Make function xfrm_dev_register static

2017-05-18 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

Fixes the following sparse warning:

net/xfrm/xfrm_device.c:141:5: warning:
 symbol 'xfrm_dev_register' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/xfrm/xfrm_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
index 8ec8a3f..50ec733 100644
--- a/net/xfrm/xfrm_device.c
+++ b/net/xfrm/xfrm_device.c
@@ -138,7 +138,7 @@ bool xfrm_dev_offload_ok(struct sk_buff *skb, struct 
xfrm_state *x)
 }
 EXPORT_SYMBOL_GPL(xfrm_dev_offload_ok);
 
-int xfrm_dev_register(struct net_device *dev)
+static int xfrm_dev_register(struct net_device *dev)
 {
if ((dev->features & NETIF_F_HW_ESP) && !dev->xfrmdev_ops)
return NOTIFY_BAD;



[PATCH net-next] net/mlx5e: Fix possible memory leak

2017-05-18 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

'encap_header' is malloced and should be freed before leaving from
the error handling cases, otherwise it will cause memory leak.

Fixes: 232c001398ae ("net/mlx5e: Add support to neighbour update flow")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 11c27e4..a72ecbc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1404,8 +1404,8 @@ static int mlx5e_create_encap_header_ipv4(struct 
mlx5e_priv *priv,
 
if (!(nud_state & NUD_VALID)) {
neigh_event_send(n, NULL);
-   neigh_release(n);
-   return -EAGAIN;
+   err = -EAGAIN;
+   goto out;
}
 
err = mlx5_encap_alloc(priv->mdev, e->tunnel_type,
@@ -1510,8 +1510,8 @@ static int mlx5e_create_encap_header_ipv6(struct 
mlx5e_priv *priv,
 
if (!(nud_state & NUD_VALID)) {
neigh_event_send(n, NULL);
-   neigh_release(n);
-   return -EAGAIN;
+   err = -EAGAIN;
+   goto out;
}
 
err = mlx5_encap_alloc(priv->mdev, e->tunnel_type,



[PATCH net-next] qed: Remove unused including

2017-05-18 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

Remove including  that is not needed.

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/qlogic/qed/qed_fcoe.c  | 1 -
 drivers/net/ethernet/qlogic/qed/qed_iscsi.c | 1 -
 drivers/net/ethernet/qlogic/qed/qed_l2.c| 1 -
 drivers/net/ethernet/qlogic/qed/qed_ll2.c   | 1 -
 drivers/net/ethernet/qlogic/qed/qed_main.c  | 1 -
 5 files changed, 5 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_fcoe.c 
b/drivers/net/ethernet/qlogic/qed/qed_fcoe.c
index 21a58ff..690dd2b 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_fcoe.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_fcoe.c
@@ -43,7 +43,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/net/ethernet/qlogic/qed/qed_iscsi.c 
b/drivers/net/ethernet/qlogic/qed/qed_iscsi.c
index 339c91d..f2fd09c 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_iscsi.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_iscsi.c
@@ -44,7 +44,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/net/ethernet/qlogic/qed/qed_l2.c 
b/drivers/net/ethernet/qlogic/qed/qed_l2.c
index 746fed4..fab6e69 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_l2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_l2.c
@@ -43,7 +43,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c 
b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
index 09c8641..b04dfc4 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
@@ -38,7 +38,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c 
b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 537d123..f286daa 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -34,7 +34,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 



[PATCH net-next] ibmvnic: fix missing unlock on error in __ibmvnic_reset()

2017-05-18 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

Add the missing unlock before return from function __ibmvnic_reset()
in the error handling case.

Fixes: ed651a10875f ("ibmvnic: Updated reset handling")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c 
b/drivers/net/ethernet/ibm/ibmvnic.c
index 4f2d329..27f7933 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1313,6 +1313,7 @@ static void __ibmvnic_reset(struct work_struct *work)
 
if (rc) {
free_all_rwi(adapter);
+   mutex_unlock(>reset_lock);
return;
}



[PATCH net-next] xen/9pfs: p9_trans_xen_init and p9_trans_xen_exit can be static

2017-05-18 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

Fixes the following sparse warnings:

net/9p/trans_xen.c:528:5: warning:
 symbol 'p9_trans_xen_init' was not declared. Should it be static?
net/9p/trans_xen.c:540:6: warning:
 symbol 'p9_trans_xen_exit' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/9p/trans_xen.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
index 71e8564..3deb17f 100644
--- a/net/9p/trans_xen.c
+++ b/net/9p/trans_xen.c
@@ -525,7 +525,7 @@ static struct xenbus_driver xen_9pfs_front_driver = {
.otherend_changed = xen_9pfs_front_changed,
 };
 
-int p9_trans_xen_init(void)
+static int p9_trans_xen_init(void)
 {
if (!xen_domain())
return -ENODEV;
@@ -537,7 +537,7 @@ int p9_trans_xen_init(void)
 }
 module_init(p9_trans_xen_init);
 
-void p9_trans_xen_exit(void)
+static void p9_trans_xen_exit(void)
 {
v9fs_unregister_trans(_xen_trans);
return xenbus_unregister_driver(_9pfs_front_driver);



[PATCH] xen/9pfs: fix return value check in xen_9pfs_front_probe()

2017-05-16 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

In case of error, the function xenbus_read() returns ERR_PTR() and never
returns NULL. The NULL test in the return value check should be replaced
with IS_ERR().

Fixes: 71ebd71921e4 ("xen/9pfs: connect to the backend")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/9p/trans_xen.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
index 71e8564..83fe487 100644
--- a/net/9p/trans_xen.c
+++ b/net/9p/trans_xen.c
@@ -454,8 +454,8 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev,
goto error_xenbus;
}
priv->tag = xenbus_read(xbt, dev->nodename, "tag", NULL);
-   if (!priv->tag) {
-   ret = -EINVAL;
+   if (IS_ERR(priv->tag)) {
+   ret = PTR_ERR(priv->tag);
goto error_xenbus;
}
ret = xenbus_transaction_end(xbt, 0);



[PATCH net-next] fib_rules: fix error return code

2017-04-26 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

Fix to return error code -EINVAL from the error handling
case instead of 0, as done elsewhere in this function.

Fixes: 622ec2c9d524 ("net: core: add UID to flows, rules, and routes")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/core/fib_rules.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index c58c1df..f21c4d3 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -440,6 +440,7 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr 
*nlh,
if (tb[FRA_TUN_ID])
rule->tun_id = nla_get_be64(tb[FRA_TUN_ID]);
 
+   err = -EINVAL;
if (tb[FRA_L3MDEV]) {
 #ifdef CONFIG_NET_L3_MASTER_DEV
rule->l3mdev = nla_get_u8(tb[FRA_L3MDEV]);
@@ -461,7 +462,6 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr 
*nlh,
else
rule->suppress_ifgroup = -1;
 
-   err = -EINVAL;
if (tb[FRA_GOTO]) {
if (rule->action != FR_ACT_GOTO)
goto errout_free;
@@ -592,8 +592,10 @@ int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr 
*nlh,
 
if (tb[FRA_UID_RANGE]) {
range = nla_get_kuid_range(tb);
-   if (!uid_range_set())
+   if (!uid_range_set()) {
+   err = -EINVAL;
goto errout;
+   }
} else {
range = fib_kuid_range_unset;
}



[PATCH net-next] drivers: net: xgene-v2: Fix error return code in xge_mdio_config()

2017-04-25 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

Fix to return error code -ENODEV from the no PHY found error
handling case instead of 0, as done elsewhere in this function.

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/apm/xgene-v2/mdio.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/apm/xgene-v2/mdio.c 
b/drivers/net/ethernet/apm/xgene-v2/mdio.c
index a583c6a..f5fe3bb 100644
--- a/drivers/net/ethernet/apm/xgene-v2/mdio.c
+++ b/drivers/net/ethernet/apm/xgene-v2/mdio.c
@@ -135,6 +135,7 @@ int xge_mdio_config(struct net_device *ndev)
phydev = phy_find_first(mdio_bus);
if (!phydev) {
dev_err(dev, "no PHY found\n");
+   ret = -ENODEV;
goto err;
}
phydev = phy_connect(ndev, phydev_name(phydev),



[PATCH net-next] qed: fix invalid use of sizeof in qed_alloc_qm_data()

2017-04-25 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

sizeof() when applied to a pointer typed expression gives the
size of the pointer, not that of the pointed data.

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/qlogic/qed/qed_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c 
b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 2498785..4fa5a1e 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -820,7 +820,7 @@ static int qed_alloc_qm_data(struct qed_hwfn *p_hwfn)
if (!qm_info->qm_vport_params)
goto alloc_err;
 
-   qm_info->qm_port_params = kzalloc(sizeof(qm_info->qm_port_params) *
+   qm_info->qm_port_params = kzalloc(sizeof(*qm_info->qm_port_params) *
  p_hwfn->cdev->num_ports_in_engines,
  GFP_KERNEL);
if (!qm_info->qm_port_params)





[PATCH net-next] can: ti_hecc: fix return value check in ti_hecc_probe()

2017-04-25 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

In case of error, the function devm_ioremap_resource() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().

Fixes: dabf54dd1c63 ("can: ti_hecc: Convert TI HECC driver to DT only driver")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/can/ti_hecc.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index b8aac53..4d49414 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -898,9 +898,9 @@ static int ti_hecc_probe(struct platform_device *pdev)
}
 
priv->base = devm_ioremap_resource(>dev, res);
-   if (!priv->base) {
+   if (IS_ERR(priv->base)) {
dev_err(>dev, "hecc ioremap failed\n");
-   return -ENOMEM;
+   return PTR_ERR(priv->base);
}
 
/* handle hecc-ram memory */
@@ -911,9 +911,9 @@ static int ti_hecc_probe(struct platform_device *pdev)
}
 
priv->hecc_ram = devm_ioremap_resource(>dev, res);
-   if (!priv->hecc_ram) {
+   if (IS_ERR(priv->hecc_ram)) {
dev_err(>dev, "hecc-ram ioremap failed\n");
-   return -ENOMEM;
+   return PTR_ERR(priv->hecc_ram);
}
 
/* handle mbx memory */
@@ -924,9 +924,9 @@ static int ti_hecc_probe(struct platform_device *pdev)
}
 
priv->mbx = devm_ioremap_resource(>dev, res);
-   if (!priv->mbx) {
+   if (IS_ERR(priv->mbx)) {
dev_err(>dev, "mbx ioremap failed\n");
-   return -ENOMEM;
+   return PTR_ERR(priv->mbx);
}
 
irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);



[PATCH net-next v2] devlink: fix return value check in devlink_dpipe_header_put()

2017-04-11 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

Fix the return value check which testing the wrong variable
in devlink_dpipe_header_put().

Fixes: 1555d204e743 ("devlink: Support for pipeline debug (dpipe)")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
Acked-by: Jiri Pirko <j...@mellanox.com>
---
v1 -> v2: fix  a typo in patch comment
---
 net/core/devlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 24b7660..0afac58 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -2031,7 +2031,7 @@ static int devlink_dpipe_header_put(struct sk_buff *skb,
int err;
 
header_attr = nla_nest_start(skb, DEVLINK_ATTR_DPIPE_HEADER);
-   if (!header)
+   if (!header_attr)
return -EMSGSIZE;
 
if (nla_put_string(skb, DEVLINK_ATTR_DPIPE_HEADER_NAME, header->name) ||



[PATCH net-next] devlink: fix return value check in devlink_dpipe_header_put()

2017-04-10 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

Fix the retrn value check which testing the wrong variable
in devlink_dpipe_header_put().

Fixes: 1555d204e743 ("devlink: Support for pipeline debug (dpipe)")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/core/devlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 24b7660..0afac58 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -2031,7 +2031,7 @@ static int devlink_dpipe_header_put(struct sk_buff *skb,
int err;
 
header_attr = nla_nest_start(skb, DEVLINK_ATTR_DPIPE_HEADER);
-   if (!header)
+   if (!header_attr)
return -EMSGSIZE;
 
if (nla_put_string(skb, DEVLINK_ATTR_DPIPE_HEADER_NAME, header->name) ||



[PATCH net-next] net_sched: nla_memdup_cookie() can be static

2017-02-14 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

Fixes the following sparse warning:

net/sched/act_api.c:532:5: warning:
 symbol 'nla_memdup_cookie' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/sched/act_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 3c5e29b..f219ff3 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -529,7 +529,7 @@ int tcf_action_dump(struct sk_buff *skb, struct list_head 
*actions,
return err;
 }
 
-int nla_memdup_cookie(struct tc_action *a, struct nlattr **tb)
+static int nla_memdup_cookie(struct tc_action *a, struct nlattr **tb)
 {
a->act_cookie = kzalloc(sizeof(*a->act_cookie), GFP_KERNEL);
if (!a->act_cookie)



[PATCH net-next] ipv6: sr: fix non static symbol warnings

2017-02-06 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

Fixes the following sparse warnings:

net/ipv6/seg6_iptunnel.c:58:5: warning:
 symbol 'nla_put_srh' was not declared. Should it be static?
net/ipv6/seg6_iptunnel.c:238:5: warning:
 symbol 'seg6_input' was not declared. Should it be static?
net/ipv6/seg6_iptunnel.c:254:5: warning:
 symbol 'seg6_output' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/ipv6/seg6_iptunnel.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c
index 6124e15..8558225 100644
--- a/net/ipv6/seg6_iptunnel.c
+++ b/net/ipv6/seg6_iptunnel.c
@@ -55,8 +55,8 @@ static const struct nla_policy 
seg6_iptunnel_policy[SEG6_IPTUNNEL_MAX + 1] = {
[SEG6_IPTUNNEL_SRH] = { .type = NLA_BINARY },
 };
 
-int nla_put_srh(struct sk_buff *skb, int attrtype,
-   struct seg6_iptunnel_encap *tuninfo)
+static int nla_put_srh(struct sk_buff *skb, int attrtype,
+  struct seg6_iptunnel_encap *tuninfo)
 {
struct seg6_iptunnel_encap *data;
struct nlattr *nla;
@@ -235,7 +235,7 @@ static int seg6_do_srh(struct sk_buff *skb)
return 0;
 }
 
-int seg6_input(struct sk_buff *skb)
+static int seg6_input(struct sk_buff *skb)
 {
int err;
 
@@ -251,7 +251,7 @@ int seg6_input(struct sk_buff *skb)
return dst_input(skb);
 }
 
-int seg6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
+static int seg6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
struct dst_entry *orig_dst = skb_dst(skb);
struct dst_entry *dst = NULL;





[PATCH net-next] net/sched: act_mirred: remove duplicated include from act_mirred.c

2017-02-06 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

Remove duplicated include.

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/sched/act_mirred.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 84682f0..af49c7d 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -28,8 +28,6 @@
 #include 
 #include 
 
-#include 
-
 #define MIRRED_TAB_MASK 7
 static LIST_HEAD(mirred_list);
 static DEFINE_SPINLOCK(mirred_list_lock);





[PATCH net-next v2] net: wan: slic_ds26522: Use module_spi_driver to simplify the code

2017-02-06 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

module_spi_driver() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/wan/slic_ds26522.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/wan/slic_ds26522.c b/drivers/net/wan/slic_ds26522.c
index 9d9b4e0..2cdcee2 100644
--- a/drivers/net/wan/slic_ds26522.c
+++ b/drivers/net/wan/slic_ds26522.c
@@ -249,15 +249,4 @@ static struct spi_driver slic_ds26522_driver = {
.id_table = slic_ds26522_id,
 };
 
-static int __init slic_ds26522_init(void)
-{
-   return spi_register_driver(_ds26522_driver);
-}
-
-static void __exit slic_ds26522_exit(void)
-{
-   spi_unregister_driver(_ds26522_driver);
-}
-
-module_init(slic_ds26522_init);
-module_exit(slic_ds26522_exit);
+module_spi_driver(slic_ds26522_driver);



[PATCH net-next v2] net: wan: slic_ds26522: Remove .owner field for driver

2017-02-06 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

Remove .owner field if calls are used which set it automatically.

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/wan/slic_ds26522.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/wan/slic_ds26522.c b/drivers/net/wan/slic_ds26522.c
index 9d9b4e0..f80fb4f 100644
--- a/drivers/net/wan/slic_ds26522.c
+++ b/drivers/net/wan/slic_ds26522.c
@@ -241,7 +241,6 @@ static struct spi_driver slic_ds26522_driver = {
.driver = {
   .name = "ds26522",
   .bus = _bus_type,
-  .owner = THIS_MODULE,
   .of_match_table = slic_ds26522_match,
   },
.probe = slic_ds26522_probe,



[PATCH net-next] lwt_bpf: bpf_lwt_prog_cmp() can be static

2017-01-12 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

Fixes the following sparse warning:

net/core/lwt_bpf.c:355:5: warning:
 symbol 'bpf_lwt_prog_cmp' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 net/core/lwt_bpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c
index 71bb3e2..40ef8ae 100644
--- a/net/core/lwt_bpf.c
+++ b/net/core/lwt_bpf.c
@@ -352,7 +352,7 @@ static int bpf_encap_nlsize(struct lwtunnel_state *lwtstate)
   0;
 }
 
-int bpf_lwt_prog_cmp(struct bpf_lwt_prog *a, struct bpf_lwt_prog *b)
+static int bpf_lwt_prog_cmp(struct bpf_lwt_prog *a, struct bpf_lwt_prog *b)
 {
/* FIXME:
 * The LWT state is currently rebuilt for delete requests which



[PATCH net-next] cdc-ether: usbnet_cdc_zte_status() can be static

2017-01-12 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

Fixes the following sparse warning:

drivers/net/usb/cdc_ether.c:469:6: warning:
 symbol 'usbnet_cdc_zte_status' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/usb/cdc_ether.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index fe7b288..620ba8e 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -466,7 +466,7 @@ static int usbnet_cdc_zte_rx_fixup(struct usbnet *dev, 
struct sk_buff *skb)
  * connected. This causes the link state to be incorrect. Work around this by
  * always setting the state to off, then on.
  */
-void usbnet_cdc_zte_status(struct usbnet *dev, struct urb *urb)
+static void usbnet_cdc_zte_status(struct usbnet *dev, struct urb *urb)
 {
struct usb_cdc_notification *event;



[PATCH net-next] net: thunderx: Fix error return code in nicvf_open()

2017-01-11 Thread Wei Yongjun
From: Wei Yongjun <weiyongj...@huawei.com>

Fix to return a negative error code from the error handling
case instead of 0, as done elsewhere in this function.

Fixes: 712c31853440 ("net: thunderx: Program LMAC credits based on MTU")
Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
---
 drivers/net/ethernet/cavium/thunder/nicvf_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c 
b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index 273eafd..a25bb6e 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -1274,7 +1274,8 @@ int nicvf_open(struct net_device *netdev)
/* Configure receive side scaling and MTU */
if (!nic->sqs_mode) {
nicvf_rss_init(nic);
-   if (nicvf_update_hw_max_frs(nic, netdev->mtu))
+   err = nicvf_update_hw_max_frs(nic, netdev->mtu);
+   if (err)
goto cleanup;
 
/* Clear percpu stats */



  1   2   3   >