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

2021-04-07 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 
---
 drivers/net/ethernet/dlink/sundance.c | 15 +--
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/dlink/sundance.c 
b/drivers/net/ethernet/dlink/sundance.c
index df0eab479d51..ce61f79f3b7c 100644
--- a/drivers/net/ethernet/dlink/sundance.c
+++ b/drivers/net/ethernet/dlink/sundance.c
@@ -1982,17 +1982,4 @@ static struct pci_driver sundance_driver = {
.driver.pm  = &sundance_pm_ops,
 };
 
-static int __init sundance_init(void)
-{
-   return pci_register_driver(&sundance_driver);
-}
-
-static void __exit sundance_exit(void)
-{
-   pci_unregister_driver(&sundance_driver);
-}
-
-module_init(sundance_init);
-module_exit(sundance_exit);
-
-
+module_pci_driver(sundance_driver);



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

2021-04-07 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 
---
 .../atheros/atlx/atl2.c| 24 +-
 1 file changed, 1 insertion(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c 
b/drivers/net/ethernet/atheros/atlx/atl2.c
index f016f2e12ee7..0cc0db04c27d 100644
--- a/drivers/net/ethernet/atheros/atlx/atl2.c
+++ b/drivers/net/ethernet/atheros/atlx/atl2.c
@@ -1675,29 +1675,7 @@ static struct pci_driver atl2_driver = {
.shutdown = atl2_shutdown,
 };
 
-/**
- * atl2_init_module - Driver Registration Routine
- *
- * atl2_init_module is the first routine called when the driver is
- * loaded. All it does is register with the PCI subsystem.
- */
-static int __init atl2_init_module(void)
-{
-   return pci_register_driver(&atl2_driver);
-}
-module_init(atl2_init_module);
-
-/**
- * atl2_exit_module - Driver Exit Cleanup Routine
- *
- * atl2_exit_module is called just before the driver is removed
- * from memory.
- */
-static void __exit atl2_exit_module(void)
-{
-   pci_unregister_driver(&atl2_driver);
-}
-module_exit(atl2_exit_module);
+module_pci_driver(atl2_driver);
 
 static void atl2_read_pci_cfg(struct atl2_hw *hw, u32 reg, u16 *value)
 {



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

2021-04-07 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 
---
 drivers/net/ethernet/fealnx.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/fealnx.c b/drivers/net/ethernet/fealnx.c
index c696651dd735..0908771aa9ac 100644
--- a/drivers/net/ethernet/fealnx.c
+++ b/drivers/net/ethernet/fealnx.c
@@ -1948,15 +1948,4 @@ static struct pci_driver fealnx_driver = {
.remove = fealnx_remove_one,
 };
 
-static int __init fealnx_init(void)
-{
-   return pci_register_driver(&fealnx_driver);
-}
-
-static void __exit fealnx_exit(void)
-{
-   pci_unregister_driver(&fealnx_driver);
-}
-
-module_init(fealnx_init);
-module_exit(fealnx_exit);
+module_pci_driver(fealnx_driver);



[PATCH net-next] tulip: windbond-840: use module_pci_driver to simplify the code

2021-04-07 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 
---
 .../ethernet/dec/tulip/winbond-840.c| 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/dec/tulip/winbond-840.c 
b/drivers/net/ethernet/dec/tulip/winbond-840.c
index 89cbdc1f4857..514df170ec5d 100644
--- a/drivers/net/ethernet/dec/tulip/winbond-840.c
+++ b/drivers/net/ethernet/dec/tulip/winbond-840.c
@@ -1629,15 +1629,4 @@ static struct pci_driver w840_driver = {
.driver.pm  = &w840_pm_ops,
 };
 
-static int __init w840_init(void)
-{
-   return pci_register_driver(&w840_driver);
-}
-
-static void __exit w840_exit(void)
-{
-   pci_unregister_driver(&w840_driver);
-}
-
-module_init(w840_init);
-module_exit(w840_exit);
+module_pci_driver(w840_driver);



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

2021-04-07 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 
---
 .../net/ethernet/dec/tulip/de2104x.c| 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c 
b/drivers/net/ethernet/dec/tulip/de2104x.c
index c3cbe55205a7..b018195f0243 100644
--- a/drivers/net/ethernet/dec/tulip/de2104x.c
+++ b/drivers/net/ethernet/dec/tulip/de2104x.c
@@ -2193,15 +2193,4 @@ static struct pci_driver de_driver = {
.driver.pm  = &de_pm_ops,
 };
 
-static int __init de_init (void)
-{
-   return pci_register_driver(&de_driver);
-}
-
-static void __exit de_exit (void)
-{
-   pci_unregister_driver (&de_driver);
-}
-
-module_init(de_init);
-module_exit(de_exit);
+module_pci_driver(de_driver);



[PATCH net-next] net: encx24j600: use module_spi_driver to simplify the code

2021-04-07 Thread Wei Yongjun
module_spi_driver() makes the code simpler by eliminating
boilerplate code.

Signed-off-by: Wei Yongjun 
---
 .../net/ethernet/microchip/encx24j600.c  | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/microchip/encx24j600.c 
b/drivers/net/ethernet/microchip/encx24j600.c
index a66a179236fd..3658c4ae3c37 100644
--- a/drivers/net/ethernet/microchip/encx24j600.c
+++ b/drivers/net/ethernet/microchip/encx24j600.c
@@ -1117,17 +1117,7 @@ static struct spi_driver encx24j600_spi_net_driver = {
.id_table   = encx24j600_spi_id_table,
 };
 
-static int __init encx24j600_init(void)
-{
-   return spi_register_driver(&encx24j600_spi_net_driver);
-}
-module_init(encx24j600_init);
-
-static void encx24j600_exit(void)
-{
-   spi_unregister_driver(&encx24j600_spi_net_driver);
-}
-module_exit(encx24j600_exit);
+module_spi_driver(encx24j600_spi_net_driver);
 
 MODULE_DESCRIPTION(DRV_NAME " ethernet driver");
 MODULE_AUTHOR("Jon Ringle ");



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

2021-04-07 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 
---
 .../net/ethernet/cisco/enic/enic_main.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c 
b/drivers/net/ethernet/cisco/enic/enic_main.c
index f04ec53544ae..f48957a17c3a 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -3040,15 +3040,4 @@ static struct pci_driver enic_driver = {
.remove = enic_remove,
 };
 
-static int __init enic_init_module(void)
-{
-   return pci_register_driver(&enic_driver);
-}
-
-static void __exit enic_cleanup_module(void)
-{
-   pci_unregister_driver(&enic_driver);
-}
-
-module_init(enic_init_module);
-module_exit(enic_cleanup_module);
+module_pci_driver(enic_driver);



[PATCH -next] mac80211: minstrel_ht: remove unused variable 'mg' in minstrel_ht_next_jump_rate()

2021-03-25 Thread Wei Yongjun
GCC reports the following warning with W=1:

net/mac80211/rc80211_minstrel_ht.c:871:34: warning:
 variable 'mg' set but not used [-Wunused-but-set-variable]
  871 |  struct minstrel_mcs_group_data *mg;
  |  ^~

This variable is not used in function , this commit
remove it to fix the warning.

Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 net/mac80211/rc80211_minstrel_ht.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index ecad9b10984f..f21c85eb906a 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -868,7 +868,6 @@ static u16
 minstrel_ht_next_jump_rate(struct minstrel_ht_sta *mi, u32 fast_rate_dur,
   u32 slow_rate_dur, int *slow_rate_ofs)
 {
-   struct minstrel_mcs_group_data *mg;
struct minstrel_rate_stats *mrs;
u32 max_duration = slow_rate_dur;
int i, index, offset;
@@ -886,7 +885,6 @@ minstrel_ht_next_jump_rate(struct minstrel_ht_sta *mi, u32 
fast_rate_dur,
u8 type;
 
group = (group + 1) % ARRAY_SIZE(minstrel_mcs_groups);
-   mg = &mi->groups[group];
 
supported = mi->supported[group];
if (!supported)



[PATCH net-next] netdevsim: switch to memdup_user_nul()

2021-03-24 Thread 'Wei Yongjun
From: Wei Yongjun 

Use memdup_user_nul() helper instead of open-coding to
simplify the code.

Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 drivers/net/netdevsim/health.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/net/netdevsim/health.c b/drivers/net/netdevsim/health.c
index 21e2974660e7..04aebdf85747 100644
--- a/drivers/net/netdevsim/health.c
+++ b/drivers/net/netdevsim/health.c
@@ -235,15 +235,10 @@ static ssize_t nsim_dev_health_break_write(struct file 
*file,
char *break_msg;
int err;
 
-   break_msg = kmalloc(count + 1, GFP_KERNEL);
-   if (!break_msg)
-   return -ENOMEM;
+   break_msg = memdup_user_nul(data, count);
+   if (IS_ERR(break_msg))
+   return PTR_ERR(break_msg);
 
-   if (copy_from_user(break_msg, data, count)) {
-   err = -EFAULT;
-   goto out;
-   }
-   break_msg[count] = '\0';
if (break_msg[count - 1] == '\n')
break_msg[count - 1] = '\0';
 



[PATCH bpf-next] bpf: Make symbol 'bpf_task_storage_busy' static

2021-03-11 Thread 'Wei Yongjun
From: Wei Yongjun 

The sparse tool complains as follows:

kernel/bpf/bpf_task_storage.c:23:1: warning:
 symbol '__pcpu_scope_bpf_task_storage_busy' was not declared. Should it be 
static?

This symbol is not used outside of bpf_task_storage.c, so this
commit marks it static.

Fixes: bc235cdb423a ("bpf: Prevent deadlock from recursive 
bpf_task_storage_[get|delete]")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 kernel/bpf/bpf_task_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/bpf_task_storage.c b/kernel/bpf/bpf_task_storage.c
index fd3c74ef608e..3ce75758d394 100644
--- a/kernel/bpf/bpf_task_storage.c
+++ b/kernel/bpf/bpf_task_storage.c
@@ -20,7 +20,7 @@
 
 DEFINE_BPF_STORAGE_CACHE(task_cache);
 
-DEFINE_PER_CPU(int, bpf_task_storage_busy);
+static DEFINE_PER_CPU(int, bpf_task_storage_busy);
 
 static void bpf_task_storage_lock(void)
 {



[PATCH -next] iwlwifi: mvm: fix old-style static const declaration

2021-03-04 Thread 'Wei Yongjun
From: Wei Yongjun 

GCC reports warning as follows:

drivers/net/wireless/intel/iwlwifi/mvm/rfi.c:14:1: warning:
 'static' is not at beginning of declaration [-Wold-style-declaration]
   14 | const static struct iwl_rfi_lut_entry iwl_rfi_table[IWL_RFI_LUT_SIZE] = 
{
  | ^

Move static to the beginning of declaration.

Fixes: 21254908cbe9 ("iwlwifi: mvm: add RFI-M support")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 drivers/net/wireless/intel/iwlwifi/mvm/rfi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rfi.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/rfi.c
index 873919048143..4d5a99cbcc9d 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rfi.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rfi.c
@@ -11,7 +11,7 @@
  * DDR needs frequency in units of 16.666MHz, so provide FW with the
  * frequency values in the adjusted format.
  */
-const static struct iwl_rfi_lut_entry iwl_rfi_table[IWL_RFI_LUT_SIZE] = {
+static const struct iwl_rfi_lut_entry iwl_rfi_table[IWL_RFI_LUT_SIZE] = {
/* LPDDR4 */
 
/* frequency 3733MHz */



[PATCH] iwlwifi: mvm: add terminate entry for dmi_system_id tables

2021-02-23 Thread Wei Yongjun
Make sure dmi_system_id tables are NULL terminated.

Fixes: a2ac0f48a07c ("iwlwifi: mvm: implement approved list for the PPAG 
feature")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
index 15e2773ce7e7..5ee64f7f3c85 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
@@ -1083,6 +1083,7 @@ static const struct dmi_system_id 
dmi_ppag_approved_list[] = {
DMI_MATCH(DMI_SYS_VENDOR, "ASUSTek COMPUTER INC."),
},
},
+   {}
 };
 
 static int iwl_mvm_ppag_init(struct iwl_mvm *mvm)



[PATCH] net: stmmac: Fix missing spin_lock_init in visconti_eth_dwmac_probe()

2021-02-23 Thread Wei Yongjun
The driver allocates the spinlock but not initialize it.
Use spin_lock_init() on it to initialize it correctly.

Fixes: b38dd98ff8d0 ("net: stmmac: Add Toshiba Visconti SoCs glue driver")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
index b7a0c57dfbfb..d23be45a64e5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
@@ -218,6 +218,7 @@ static int visconti_eth_dwmac_probe(struct platform_device 
*pdev)
goto remove_config;
}
 
+   spin_lock_init(&dwmac->lock);
dwmac->reg = stmmac_res.addr;
plat_dat->bsp_priv = dwmac;
plat_dat->fix_mac_speed = visconti_eth_fix_mac_speed;



[PATCH net-next] net/mlx5: SF, Fix error return code in mlx5_sf_dev_probe()

2021-02-09 Thread Wei Yongjun
Fix to return negative error code -ENOMEM from the ioremap() error
handling case instead of 0, as done elsewhere in this function.

Fixes: 1958fc2f0712 ("net/mlx5: SF, Add auxiliary device driver")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 .../net/ethernet/mellanox/mlx5/core/sf/dev/driver.c  | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c 
b/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c
index daf63a8115e0..c4bf555c25ea 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c
@@ -37,6 +37,7 @@ static int mlx5_sf_dev_probe(struct auxiliary_device *adev, 
const struct auxilia
mdev->iseg = ioremap(mdev->iseg_base, sizeof(*mdev->iseg));
if (!mdev->iseg) {
mlx5_core_warn(mdev, "remap error\n");
+   err = -ENOMEM;
goto remap_err;
}
 



[PATCH net-next] net/mlx5e: Fix error return code in mlx5e_tc_esw_init()

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

This commit also using 0 instead of 'ret' when success since it is
always equal to 0.

Fixes: 8914add2c9e5 ("net/mlx5e: Handle FIB events to update tunnel endpoint 
device")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c 
b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index db142ee96510..9f126054d371 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -4750,10 +4750,12 @@ int mlx5e_tc_esw_init(struct rhashtable *tc_ht)
lockdep_set_class(&tc_ht->mutex, &tc_ht_lock_key);
 
uplink_priv->encap = mlx5e_tc_tun_init(priv);
-   if (IS_ERR(uplink_priv->encap))
+   if (IS_ERR(uplink_priv->encap)) {
+   err = PTR_ERR(uplink_priv->encap);
goto err_register_fib_notifier;
+   }
 
-   return err;
+   return 0;
 
 err_register_fib_notifier:
rhashtable_destroy(tc_ht);



[PATCH] Bluetooth: sco: Fix crash when using BT_SNDMTU/BT_RCVMTU option

2020-11-16 Thread Wei Yongjun
This commit add the invalid check for connected socket, without it will
causes the following crash due to sco_pi(sk)->conn being NULL:

KASAN: null-ptr-deref in range [0x0050-0x0057]
CPU: 3 PID: 4284 Comm: test_sco Not tainted 5.10.0-rc3+ #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1 
04/01/2014
RIP: 0010:sco_sock_getsockopt+0x45d/0x8e0
Code: 48 c1 ea 03 80 3c 02 00 0f 85 ca 03 00 00 49 8b 9d f8 04 00 00 48 b8 00
  00 00 00 00 fc ff df 48 8d 7b 50 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84
  c0 74 08 3c 03 0f 8e b5 03 00 00 8b 43 50 48 8b 0c
RSP: 0018:88801bb17d88 EFLAGS: 00010206
RAX: dc00 RBX:  RCX: 83a4ecdf
RDX: 000a RSI: c90002fce000 RDI: 0050
RBP: 111003762fb4 R08: 0001 R09: 88810e1008c0
R10: bd695dcf R11: fbfff7ad2bb9 R12: 
R13: 888018ff1000 R14: dc00 R15: 000d
FS:  7fb4f76c1700() GS:88811af8() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: e3b7a938 CR3: 0001117be001 CR4: 00770ee0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
PKRU: 5554
Call Trace:
 ? sco_skb_put_cmsg+0x80/0x80
 ? sco_skb_put_cmsg+0x80/0x80
 __sys_getsockopt+0x12a/0x220
 ? __ia32_sys_setsockopt+0x150/0x150
 ? syscall_enter_from_user_mode+0x18/0x50
 ? rcu_read_lock_bh_held+0xb0/0xb0
 __x64_sys_getsockopt+0xba/0x150
 ? syscall_enter_from_user_mode+0x1d/0x50
 do_syscall_64+0x33/0x40
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Fixes: 0fc1a726f897 ("Bluetooth: sco: new getsockopt options 
BT_SNDMTU/BT_RCVMTU")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 

diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 79ffcdef0b7a..22a110f37abc 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -1003,6 +1003,11 @@ static int sco_sock_getsockopt(struct socket *sock, int 
level, int optname,
 
case BT_SNDMTU:
case BT_RCVMTU:
+   if (sk->sk_state != BT_CONNECTED) {
+   err = -ENOTCONN;
+   break;
+   }
+
if (put_user(sco_pi(sk)->conn->mtu, (u32 __user *)optval))
err = -EFAULT;
break;
-- 
2.25.1



[PATCH net-next] ice: mark PM functions as __maybe_unused

2020-07-27 Thread Wei Yongjun
In certain configurations without power management support, the
following warnings happen:

drivers/net/ethernet/intel/ice/ice_main.c:4214:12: warning:
 'ice_resume' defined but not used [-Wunused-function]
 4214 | static int ice_resume(struct device *dev)
  |^~
drivers/net/ethernet/intel/ice/ice_main.c:4150:12: warning:
 'ice_suspend' defined but not used [-Wunused-function]
 4150 | static int ice_suspend(struct device *dev)
  |^~~

Mark these functions as __maybe_unused to make it clear to the
compiler that this is going to happen based on the configuration,
which is the standard for these types of functions.

Fixes: 769c500dcc1e ("ice: Add advanced power mgmt for WoL")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/intel/ice/ice_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_main.c 
b/drivers/net/ethernet/intel/ice/ice_main.c
index d6981ba34b27..6edf018c4940 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -4147,7 +4147,7 @@ static int ice_reinit_interrupt_scheme(struct ice_pf *pf)
  * Power Management callback to quiesce the device and prepare
  * for D3 transition.
  */
-static int ice_suspend(struct device *dev)
+static int __maybe_unused ice_suspend(struct device *dev)
 {
struct pci_dev *pdev = to_pci_dev(dev);
struct ice_pf *pf;
@@ -4211,7 +4211,7 @@ static int ice_suspend(struct device *dev)
  * ice_resume - PM callback for waking up from D3
  * @dev: generic device information structure
  */
-static int ice_resume(struct device *dev)
+static int __maybe_unused ice_resume(struct device *dev)
 {
struct pci_dev *pdev = to_pci_dev(dev);
enum ice_reset_req reset_type;



Re: [PATCH v2 net] rtnetlink: Fix memory(net_device) leak when ->newlink fails

2020-07-13 Thread Wei Yongjun



On 2020/7/14 15:32, Weilong Chen wrote:
> When vlan_newlink call register_vlan_dev fails, it might return error
> with dev->reg_state = NETREG_UNREGISTERED. The rtnl_newlink should
> free the memory. But currently rtnl_newlink only free the memory which
> state is NETREG_UNINITIALIZED.
> 
> BUG: memory leak
> unreferenced object 0x8881051de000 (size 4096):
>   comm "syz-executor139", pid 560, jiffies 4294745346 (age 32.445s)
>   hex dump (first 32 bytes):
> 76 6c 61 6e 32 00 00 00 00 00 00 00 00 00 00 00  vlan2...
> 00 45 28 03 81 88 ff ff 00 00 00 00 00 00 00 00  .E(.
>   backtrace:
> [<47527e31>] kmalloc_node include/linux/slab.h:578 [inline]
> [<47527e31>] kvmalloc_node+0x33/0xd0 mm/util.c:574
> [<2b59e3bc>] kvmalloc include/linux/mm.h:753 [inline]
> [<2b59e3bc>] kvzalloc include/linux/mm.h:761 [inline]
> [<2b59e3bc>] alloc_netdev_mqs+0x83/0xd90 net/core/dev.c:9929
> [<6076752a>] rtnl_create_link+0x2c0/0xa20 
> net/core/rtnetlink.c:3067
> [<572b3be5>] __rtnl_newlink+0xc9c/0x1330 net/core/rtnetlink.c:3329
> [] rtnl_newlink+0x66/0x90 net/core/rtnetlink.c:3397
> [<52c7c0a9>] rtnetlink_rcv_msg+0x540/0x990 
> net/core/rtnetlink.c:5460
> [<4b5cb379>] netlink_rcv_skb+0x12b/0x3a0 
> net/netlink/af_netlink.c:2469
> [] netlink_unicast_kernel net/netlink/af_netlink.c:1303 
> [inline]
> [] netlink_unicast+0x4c6/0x690 
> net/netlink/af_netlink.c:1329
> [] netlink_sendmsg+0x735/0xcc0 
> net/netlink/af_netlink.c:1918
> [<9221ebf7>] sock_sendmsg_nosec net/socket.c:652 [inline]
> [<9221ebf7>] sock_sendmsg+0x109/0x140 net/socket.c:672
> [<1c30ffe4>] sys_sendmsg+0x5f5/0x780 net/socket.c:2352
> [] ___sys_sendmsg+0x11d/0x1a0 net/socket.c:2406
> [<07297384>] __sys_sendmsg+0xeb/0x1b0 net/socket.c:2439
> [<0eb29b11>] do_syscall_64+0x56/0xa0 arch/x86/entry/common.c:359
> [<6839b4d0>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
> 
> Fixes: commit e51fb152318ee6 (rtnetlink: fix a memory leak when ->newlink 
> fails)

Should be:

Fixes: e51fb152318ee6 ("rtnetlink: fix a memory leak when ->newlink fails")



[PATCH] ip6_gre: fix null-ptr-deref in ip6gre_init_net()

2020-07-13 Thread Wei Yongjun
KASAN report null-ptr-deref error when register_netdev() failed:

KASAN: null-ptr-deref in range [0x03c0-0x03c7]
CPU: 2 PID: 422 Comm: ip Not tainted 5.8.0-rc4+ #12
Call Trace:
 ip6gre_init_net+0x4ab/0x580
 ? ip6gre_tunnel_uninit+0x3f0/0x3f0
 ops_init+0xa8/0x3c0
 setup_net+0x2de/0x7e0
 ? rcu_read_lock_bh_held+0xb0/0xb0
 ? ops_init+0x3c0/0x3c0
 ? kasan_unpoison_shadow+0x33/0x40
 ? __kasan_kmalloc.constprop.0+0xc2/0xd0
 copy_net_ns+0x27d/0x530
 create_new_namespaces+0x382/0xa30
 unshare_nsproxy_namespaces+0xa1/0x1d0
 ksys_unshare+0x39c/0x780
 ? walk_process_tree+0x2a0/0x2a0
 ? trace_hardirqs_on+0x4a/0x1b0
 ? _raw_spin_unlock_irq+0x1f/0x30
 ? syscall_trace_enter+0x1a7/0x330
 ? do_syscall_64+0x1c/0xa0
 __x64_sys_unshare+0x2d/0x40
 do_syscall_64+0x56/0xa0
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

ip6gre_tunnel_uninit() has set 'ign->fb_tunnel_dev' to NULL, later
access to ign->fb_tunnel_dev cause null-ptr-deref. Fix it by saving
'ign->fb_tunnel_dev' to local variable ndev.

Fixes: dafabb6590cb ("ip6_gre: fix use-after-free in ip6gre_tunnel_lookup()")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 6532bde82b40..3a57fb9ce049 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1562,17 +1562,18 @@ static void ip6gre_destroy_tunnels(struct net *net, 
struct list_head *head)
 static int __net_init ip6gre_init_net(struct net *net)
 {
struct ip6gre_net *ign = net_generic(net, ip6gre_net_id);
+   struct net_device *ndev;
int err;
 
if (!net_has_fallback_tunnels(net))
return 0;
-   ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6gre0",
- NET_NAME_UNKNOWN,
- ip6gre_tunnel_setup);
-   if (!ign->fb_tunnel_dev) {
+   ndev = alloc_netdev(sizeof(struct ip6_tnl), "ip6gre0",
+   NET_NAME_UNKNOWN, ip6gre_tunnel_setup);
+   if (!ndev) {
err = -ENOMEM;
goto err_alloc_dev;
}
+   ign->fb_tunnel_dev = ndev;
dev_net_set(ign->fb_tunnel_dev, net);
/* FB netdevice is special: we have one, and only one per netns.
 * Allowing to move it to another netns is clearly unsafe.
@@ -1592,7 +1593,7 @@ static int __net_init ip6gre_init_net(struct net *net)
return 0;
 
 err_reg_dev:
-   free_netdev(ign->fb_tunnel_dev);
+   free_netdev(ndev);
 err_alloc_dev:
return err;
 }
-- 
2.25.1



[PATCH net-next v2] net: make symbol 'flush_works' static

2020-07-13 Thread Wei Yongjun
The sparse tool complains as follows:

net/core/dev.c:5594:1: warning:
 symbol '__pcpu_scope_flush_works' was not declared. Should it be static?

'flush_works' is not used outside of dev.c, so marks
it static.

Fixes: 41852497a9205 ("net: batch calls to flush_all_backlogs()")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
v1 - > v2: add fixes tag
---
 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index eab4ebe3c21c..b61075828358 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5591,7 +5591,7 @@ void netif_receive_skb_list(struct list_head *head)
 }
 EXPORT_SYMBOL(netif_receive_skb_list);
 
-DEFINE_PER_CPU(struct work_struct, flush_works);
+static DEFINE_PER_CPU(struct work_struct, flush_works);
 
 /* Network device is going away, flush any packets still pending */
 static void flush_backlog(struct work_struct *work)



[PATCH net-next] net: make symbol 'flush_works' static

2020-07-10 Thread Wei Yongjun
The sparse tool complains as follows:

net/core/dev.c:5594:1: warning:
 symbol '__pcpu_scope_flush_works' was not declared. Should it be static?

'flush_works' is not used outside of dev.c, so marks
it static.

Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index eab4ebe3c21c..b61075828358 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5591,7 +5591,7 @@ void netif_receive_skb_list(struct list_head *head)
 }
 EXPORT_SYMBOL(netif_receive_skb_list);
 
-DEFINE_PER_CPU(struct work_struct, flush_works);
+static DEFINE_PER_CPU(struct work_struct, flush_works);
 
 /* Network device is going away, flush any packets still pending */
 static void flush_backlog(struct work_struct *work)



[PATCH net-next] sun/cassini: mark cas_resume() as __maybe_unused

2020-07-07 Thread Wei Yongjun
In certain configurations without power management support, gcc report
the following warning:

drivers/net/ethernet/sun/cassini.c:5206:12: warning:
 'cas_resume' defined but not used [-Wunused-function]
 5206 | static int cas_resume(struct device *dev_d)
  |^~

Mark cas_resume() as __maybe_unused to make it clear.

Fixes: f193f4ebde3d ("sun/cassini: use generic power management")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/sun/cassini.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/sun/cassini.c 
b/drivers/net/ethernet/sun/cassini.c
index 95c07cc84053..e04c3d73a246 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -5203,7 +5203,7 @@ static int __maybe_unused cas_suspend(struct device 
*dev_d)
return 0;
 }
 
-static int cas_resume(struct device *dev_d)
+static int __maybe_unused cas_resume(struct device *dev_d)
 {
struct net_device *dev = dev_get_drvdata(dev_d);
struct cas *cp = netdev_priv(dev);



[PATCH -next] perf/core: Make some symbols static

2020-07-06 Thread Wei Yongjun
sparse report build warning as follows:

kernel/events/core.c:6493:6: warning: symbol
 'perf_pmu_snapshot_aux' was not declared. Should it be static?
kernel/events/core.c:10545:1: warning: symbol
 'dev_attr_nr_addr_filters' was not declared. Should it be static?
 
'perf_pmu_snapshot_aux' and 'dev_attr_nr_addr_filters' are not used
outside of this file, so mark them static.

Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 kernel/events/core.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 1449553a8d44..9465f30ad981 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6490,10 +6490,10 @@ static unsigned long perf_prepare_sample_aux(struct 
perf_event *event,
return data->aux_size;
 }
 
-long perf_pmu_snapshot_aux(struct perf_buffer *rb,
-  struct perf_event *event,
-  struct perf_output_handle *handle,
-  unsigned long size)
+static long perf_pmu_snapshot_aux(struct perf_buffer *rb,
+ struct perf_event *event,
+ struct perf_output_handle *handle,
+ unsigned long size)
 {
unsigned long flags;
long ret;
@@ -10542,7 +10542,7 @@ static ssize_t nr_addr_filters_show(struct device *dev,
 
return snprintf(page, PAGE_SIZE - 1, "%d\n", pmu->nr_addr_filters);
 }
-DEVICE_ATTR_RO(nr_addr_filters);
+static DEVICE_ATTR_RO(nr_addr_filters);
 
 static struct idr pmu_idr;
 



Re: [PATCH net-next] mlx4: Mark PM functions as __maybe_unused

2020-07-02 Thread Wei Yongjun



On 2020/7/2 17:36, Leon Romanovsky wrote:
> On Thu, Jul 02, 2020 at 05:19:46PM +0800, Wei Yongjun wrote:
>> In certain configurations without power management support, the
>> following warnings happen:
>>
>> drivers/net/ethernet/mellanox/mlx4/main.c:4388:12:
>>  warning: 'mlx4_resume' defined but not used [-Wunused-function]
>>  4388 | static int mlx4_resume(struct device *dev_d)
>>   |^~~
>> drivers/net/ethernet/mellanox/mlx4/main.c:4373:12: warning:
>>  'mlx4_suspend' defined but not used [-Wunused-function]
>>  4373 | static int mlx4_suspend(struct device *dev_d)
>>   |^~~~
>>
>> Mark these functions as __maybe_unused to make it clear to the
>> compiler that this is going to happen based on the configuration,
>> which is the standard for these types of functions.
>>
>> Fixes: 0e3e206a3e12 ("mlx4: use generic power management")
> 
> I can't find this SHA-1, where did you get it?

It is in the net-next tree.

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=0e3e206a3e12

> And why doesn't mlx5 need this change?
> 
> Fixes: 86a3e5d02c20 ("net/mlx4_core: Add PCI calls for suspend/resume")
> 
> Thanks
> 


[PATCH net-next] mlx4: Mark PM functions as __maybe_unused

2020-07-02 Thread Wei Yongjun
In certain configurations without power management support, the
following warnings happen:

drivers/net/ethernet/mellanox/mlx4/main.c:4388:12:
 warning: 'mlx4_resume' defined but not used [-Wunused-function]
 4388 | static int mlx4_resume(struct device *dev_d)
  |^~~
drivers/net/ethernet/mellanox/mlx4/main.c:4373:12: warning:
 'mlx4_suspend' defined but not used [-Wunused-function]
 4373 | static int mlx4_suspend(struct device *dev_d)
  |^~~~
  
Mark these functions as __maybe_unused to make it clear to the
compiler that this is going to happen based on the configuration,
which is the standard for these types of functions.

Fixes: 0e3e206a3e12 ("mlx4: use generic power management")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/mellanox/mlx4/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c 
b/drivers/net/ethernet/mellanox/mlx4/main.c
index 4cae7db8d49c..954c22c79f6b 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -4370,7 +4370,7 @@ static const struct pci_error_handlers mlx4_err_handler = 
{
.resume = mlx4_pci_resume,
 };
 
-static int mlx4_suspend(struct device *dev_d)
+static int __maybe_unused mlx4_suspend(struct device *dev_d)
 {
struct pci_dev *pdev = to_pci_dev(dev_d);
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
@@ -4385,7 +4385,7 @@ static int mlx4_suspend(struct device *dev_d)
return 0;
 }
 
-static int mlx4_resume(struct device *dev_d)
+static int __maybe_unused mlx4_resume(struct device *dev_d)
 {
struct pci_dev *pdev = to_pci_dev(dev_d);
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);



[PATCH net-next] ksz884x: mark pcidev_suspend() as __maybe_unused

2020-07-02 Thread Wei Yongjun
In certain configurations without power management support, gcc report
the following warning:

drivers/net/ethernet/micrel/ksz884x.c:7182:12: warning:
 'pcidev_suspend' defined but not used [-Wunused-function]
 7182 | static int pcidev_suspend(struct device *dev_d)
  |^~

Mark pcidev_suspend() as __maybe_unused to make it clear.

Fixes: 64120615d140 ("ksz884x: use generic power management")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/micrel/ksz884x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/micrel/ksz884x.c 
b/drivers/net/ethernet/micrel/ksz884x.c
index 24901342ecc0..2ce7304d3753 100644
--- a/drivers/net/ethernet/micrel/ksz884x.c
+++ b/drivers/net/ethernet/micrel/ksz884x.c
@@ -7179,7 +7179,7 @@ static int __maybe_unused pcidev_resume(struct device 
*dev_d)
return 0;
 }
 
-static int pcidev_suspend(struct device *dev_d)
+static int __maybe_unused pcidev_suspend(struct device *dev_d)
 {
int i;
struct platform_info *info = dev_get_drvdata(dev_d);



[PATCH net-next] qed: Make symbol 'qed_hw_err_type_descr' static

2020-07-01 Thread Wei Yongjun
From: Hulk Robot 

Fix sparse build warning:

drivers/net/ethernet/qlogic/qed/qed_main.c:2480:6: warning:
 symbol 'qed_hw_err_type_descr' was not declared. Should it be static?

Signed-off-by: Hulk Robot 
---
 drivers/net/ethernet/qlogic/qed/qed_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c 
b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 11367a248d55..0a23b788b842 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -2477,7 +2477,7 @@ void qed_schedule_recovery_handler(struct qed_hwfn 
*p_hwfn)
ops->schedule_recovery_handler(cookie);
 }
 
-char *qed_hw_err_type_descr[] = {
+static char *qed_hw_err_type_descr[] = {
[QED_HW_ERR_FAN_FAIL]   = "Fan Failure",
[QED_HW_ERR_MFW_RESP_FAIL]  = "MFW Response Failure",
[QED_HW_ERR_HW_ATTN]= "HW Attention",



[PATCH] iavf: fix error return code in iavf_init_get_resources()

2020-06-18 Thread Wei Yongjun
Fix to return negative error code -ENOMEM from the error handling
case instead of 0, as done elsewhere in this function.

Fixes: b66c7bc1cd4d ("iavf: Refactor init state machine")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c 
b/drivers/net/ethernet/intel/iavf/iavf_main.c
index fa82768e5eda..bc83e2d99944 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -1863,8 +1863,10 @@ static int iavf_init_get_resources(struct iavf_adapter 
*adapter)
 
adapter->rss_key = kzalloc(adapter->rss_key_size, GFP_KERNEL);
adapter->rss_lut = kzalloc(adapter->rss_lut_size, GFP_KERNEL);
-   if (!adapter->rss_key || !adapter->rss_lut)
+   if (!adapter->rss_key || !adapter->rss_lut) {
+   err = -ENOMEM;
goto err_mem;
+   }
if (RSS_AQ(adapter))
adapter->aq_required |= IAVF_FLAG_AQ_CONFIGURE_RSS;
else





[PATCH net v2] mptcp: fix memory leak in mptcp_subflow_create_socket()

2020-06-14 Thread Wei Yongjun
socket malloced  by sock_create_kern() should be release before return
in the error handling, otherwise it cause memory leak.

unreferenced object 0x88810910c000 (size 1216):
  comm "0003_test_m", pid 12238, jiffies 4295050289 (age 54.237s)
  hex dump (first 32 bytes):
01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00  
00 00 00 00 00 00 00 00 00 2f 30 0a 81 88 ff ff  ./0.
  backtrace:
[<e877f89f>] sock_alloc_inode+0x18/0x1c0
[<93d1dd51>] alloc_inode+0x63/0x1d0
[<5673fec6>] new_inode_pseudo+0x14/0xe0
[<b5db6be8>] sock_alloc+0x3c/0x260
[<e7e3cbb2>] __sock_create+0x89/0x620
[<23e48593>] mptcp_subflow_create_socket+0xc0/0x5e0
[<419795e4>] __mptcp_socket_create+0x1ad/0x3f0
[<b2f942e8>] mptcp_stream_connect+0x281/0x4f0
[<c80cd5cc>] __sys_connect_file+0x14d/0x190
[<dc761f11>] __sys_connect+0x128/0x160
[<8b14e764>] __x64_sys_connect+0x6f/0xb0
[<7b4f93bd>] do_syscall_64+0xa1/0x530
[<d3e770b6>] entry_SYSCALL_64_after_hwframe+0x49/0xb3

Fixes: 2303f994b3e1 ("mptcp: Associate MPTCP context with TCP socket")
Signed-off-by: Wei Yongjun 
---
v1 -> v2: add net prefix to subject line
---
 net/mptcp/subflow.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index bf132575040d..bbdb74b8bc3c 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -1053,8 +1053,10 @@ int mptcp_subflow_create_socket(struct sock *sk, struct 
socket **new_sock)
err = tcp_set_ulp(sf->sk, "mptcp");
release_sock(sf->sk);
 
-   if (err)
+   if (err) {
+   sock_release(sf);
return err;
+   }
 
/* the newly created socket really belongs to the owning MPTCP master
 * socket, even if for additional subflows the allocation is performed
-- 
2.25.1



[PATCH] mptcp: fix memory leak in mptcp_subflow_create_socket()

2020-06-12 Thread Wei Yongjun
socket malloced  by sock_create_kern() should be release before return
in the error handling, otherwise it cause memory leak.

unreferenced object 0x88810910c000 (size 1216):
  comm "0003_test_m", pid 12238, jiffies 4295050289 (age 54.237s)
  hex dump (first 32 bytes):
01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00  
00 00 00 00 00 00 00 00 00 2f 30 0a 81 88 ff ff  ./0.
  backtrace:
[<e877f89f>] sock_alloc_inode+0x18/0x1c0
[<93d1dd51>] alloc_inode+0x63/0x1d0
[<5673fec6>] new_inode_pseudo+0x14/0xe0
[<b5db6be8>] sock_alloc+0x3c/0x260
[<e7e3cbb2>] __sock_create+0x89/0x620
[<23e48593>] mptcp_subflow_create_socket+0xc0/0x5e0
[<419795e4>] __mptcp_socket_create+0x1ad/0x3f0
[<b2f942e8>] mptcp_stream_connect+0x281/0x4f0
[<c80cd5cc>] __sys_connect_file+0x14d/0x190
[<dc761f11>] __sys_connect+0x128/0x160
[<8b14e764>] __x64_sys_connect+0x6f/0xb0
[<7b4f93bd>] do_syscall_64+0xa1/0x530
[<d3e770b6>] entry_SYSCALL_64_after_hwframe+0x49/0xb3

Fixes: 2303f994b3e1 ("mptcp: Associate MPTCP context with TCP socket")
Signed-off-by: Wei Yongjun 

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index bf132575040d..bbdb74b8bc3c 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -1053,8 +1053,10 @@ int mptcp_subflow_create_socket(struct sock *sk, struct 
socket **new_sock)
err = tcp_set_ulp(sf->sk, "mptcp");
release_sock(sf->sk);
 
-   if (err)
+   if (err) {
+   sock_release(sf);
return err;
+   }
 
/* the newly created socket really belongs to the owning MPTCP master
 * socket, even if for additional subflows the allocation is performed
-- 
2.25.1



[PATCH 1/2 v3] net: ethernet: ti: fix some return value check of cpsw_ale_create()

2020-05-19 Thread Wei Yongjun
cpsw_ale_create() can return both NULL and PTR_ERR(), but all of
the caller only check NULL for error handling. This patch convert
it to only return PTR_ERR() in all error cases, and the caller using
IS_ERR() instead of NULL test.

Fixes: 4b41d3436796 ("net: ethernet: ti: cpsw: allow untagged traffic on host 
port")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/ti/cpsw_ale.c| 2 +-
 drivers/net/ethernet/ti/cpsw_priv.c   | 4 ++--
 drivers/net/ethernet/ti/netcp_ethss.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw_ale.c 
b/drivers/net/ethernet/ti/cpsw_ale.c
index 0374e6936091..8dc6be11b2ff 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -955,7 +955,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params 
*params)
 
ale = devm_kzalloc(params->dev, sizeof(*ale), GFP_KERNEL);
if (!ale)
-   return NULL;
+   return ERR_PTR(-ENOMEM);
 
ale->p0_untag_vid_mask =
devm_kmalloc_array(params->dev, BITS_TO_LONGS(VLAN_N_VID),
diff --git a/drivers/net/ethernet/ti/cpsw_priv.c 
b/drivers/net/ethernet/ti/cpsw_priv.c
index 97a058ca60ac..d0b6c418a870 100644
--- a/drivers/net/ethernet/ti/cpsw_priv.c
+++ b/drivers/net/ethernet/ti/cpsw_priv.c
@@ -490,9 +490,9 @@ int cpsw_init_common(struct cpsw_common *cpsw, void __iomem 
*ss_regs,
ale_params.ale_ports= CPSW_ALE_PORTS_NUM;
 
cpsw->ale = cpsw_ale_create(&ale_params);
-   if (!cpsw->ale) {
+   if (IS_ERR(cpsw->ale)) {
dev_err(dev, "error initializing ale engine\n");
-   return -ENODEV;
+   return PTR_ERR(cpsw->ale);
}
 
dma_params.dev  = dev;
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c 
b/drivers/net/ethernet/ti/netcp_ethss.c
index fb36115e9c51..fdbae734acce 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -3704,9 +3704,9 @@ static int gbe_probe(struct netcp_device *netcp_device, 
struct device *dev,
ale_params.nu_switch_ale = true;
}
gbe_dev->ale = cpsw_ale_create(&ale_params);
-   if (!gbe_dev->ale) {
+   if (IS_ERR(gbe_dev->ale)) {
dev_err(gbe_dev->dev, "error initializing ale engine\n");
-   ret = -ENODEV;
+   ret = PTR_ERR(gbe_dev->ale);
goto free_sec_ports;
} else {
dev_dbg(gbe_dev->dev, "Created a gbe ale engine\n");
-- 
2.25.1



[PATCH 2/2 v3] net: ethernet: ti: am65-cpsw-nuss: fix error handling of am65_cpsw_nuss_probe

2020-05-19 Thread Wei Yongjun
Convert to using IS_ERR() instead of NULL test for cpsw_ale_create()
error handling. Also fix to return negative error code from this error
handling case instead of 0 in.

Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth 
subsystem driver")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c 
b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 2517ffba8178..88f52a2f85b3 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -1895,8 +1895,9 @@ static int am65_cpsw_nuss_probe(struct platform_device 
*pdev)
ale_params.nu_switch_ale = true;
 
common->ale = cpsw_ale_create(&ale_params);
-   if (!common->ale) {
+   if (IS_ERR(common->ale)) {
dev_err(dev, "error initializing ale engine\n");
+   ret = PTR_ERR(common->ale);
goto err_of_clear;
}
 
-- 
2.25.1



[PATCH 0/2 v3] net: ethernet: ti: fix some return value check

2020-05-19 Thread Wei Yongjun
This patchset convert cpsw_ale_create() to return PTR_ERR() only, and
changed all the caller to check IS_ERR() instead of NULL.

Since v2:
1) rebased on net.git, as Jakub's suggest
2) split am65-cpsw-nuss.c changes, as Grygorii's suggest


Wei Yongjun (2):
  net: ethernet: ti: fix some return value check of cpsw_ale_create()
  net: ethernet: ti: am65-cpsw-nuss: fix error handling of
am65_cpsw_nuss_probe

 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 3 ++-
 drivers/net/ethernet/ti/cpsw_ale.c   | 2 +-
 drivers/net/ethernet/ti/cpsw_priv.c  | 4 ++--
 drivers/net/ethernet/ti/netcp_ethss.c| 4 ++--
 4 files changed, 7 insertions(+), 6 deletions(-)

-- 
2.25.1



[PATCH net-next] net: dsa: vsc73xx: convert to devm_platform_ioremap_resource

2020-05-08 Thread Wei Yongjun
Use the helper function that wraps the calls to platform_get_resource()
and devm_ioremap_resource() together.

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

diff --git a/drivers/net/dsa/vitesse-vsc73xx-platform.c 
b/drivers/net/dsa/vitesse-vsc73xx-platform.c
index 0541785f9fee..5e54a5726aa4 100644
--- a/drivers/net/dsa/vitesse-vsc73xx-platform.c
+++ b/drivers/net/dsa/vitesse-vsc73xx-platform.c
@@ -89,7 +89,6 @@ static int vsc73xx_platform_probe(struct platform_device 
*pdev)
 {
struct device *dev = &pdev->dev;
struct vsc73xx_platform *vsc_platform;
-   struct resource *res = NULL;
int ret;
 
vsc_platform = devm_kzalloc(dev, sizeof(*vsc_platform), GFP_KERNEL);
@@ -103,14 +102,7 @@ static int vsc73xx_platform_probe(struct platform_device 
*pdev)
vsc_platform->vsc.ops = &vsc73xx_platform_ops;
 
/* obtain I/O memory space */
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res) {
-   dev_err(&pdev->dev, "cannot obtain I/O memory space\n");
-   ret = -ENXIO;
-   return ret;
-   }
-
-   vsc_platform->base_addr = devm_ioremap_resource(&pdev->dev, res);
+   vsc_platform->base_addr = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(vsc_platform->base_addr)) {
dev_err(&pdev->dev, "cannot request I/O memory space\n");
ret = -ENXIO;







[PATCH net-next v2] net: ethernet: ti: fix some return value check of cpsw_ale_create()

2020-05-08 Thread Wei Yongjun
cpsw_ale_create() can return both NULL and PTR_ERR(), but all of
the caller only check NULL for error handling. This patch convert
it to only return PTR_ERR() in all error cases, all the caller using
IS_ERR() install of NULL test.

Also fix a return negative error code from the cpsw_ale_create()
error handling case instead of 0 in am65_cpsw_nuss_probe().

Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth 
subsystem driver")
Fixes: 4b41d3436796 ("net: ethernet: ti: cpsw: allow untagged traffic on host 
port")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
v1 -> v2: fix cpsw_ale_create() to retuen PTR_ERR() in all places as Grygorii's 
suggest
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 3 ++-
 drivers/net/ethernet/ti/cpsw_ale.c   | 2 +-
 drivers/net/ethernet/ti/cpsw_priv.c  | 4 ++--
 drivers/net/ethernet/ti/netcp_ethss.c| 4 ++--
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c 
b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 8cdbb2b9b13a..5530d7ef77a6 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -2074,8 +2074,9 @@ static int am65_cpsw_nuss_probe(struct platform_device 
*pdev)
ale_params.nu_switch_ale = true;
 
common->ale = cpsw_ale_create(&ale_params);
-   if (!common->ale) {
+   if (IS_ERR(common->ale)) {
dev_err(dev, "error initializing ale engine\n");
+   ret = ERR_PTR(common->ale);
goto err_of_clear;
}
 
diff --git a/drivers/net/ethernet/ti/cpsw_ale.c 
b/drivers/net/ethernet/ti/cpsw_ale.c
index 0374e6936091..8dc6be11b2ff 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -955,7 +955,7 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params 
*params)
 
ale = devm_kzalloc(params->dev, sizeof(*ale), GFP_KERNEL);
if (!ale)
-   return NULL;
+   return ERR_PTR(-ENOMEM);
 
ale->p0_untag_vid_mask =
devm_kmalloc_array(params->dev, BITS_TO_LONGS(VLAN_N_VID),
diff --git a/drivers/net/ethernet/ti/cpsw_priv.c 
b/drivers/net/ethernet/ti/cpsw_priv.c
index 9d098c802c6d..d940628bff8d 100644
--- a/drivers/net/ethernet/ti/cpsw_priv.c
+++ b/drivers/net/ethernet/ti/cpsw_priv.c
@@ -504,9 +504,9 @@ int cpsw_init_common(struct cpsw_common *cpsw, void __iomem 
*ss_regs,
ale_params.ale_ports= CPSW_ALE_PORTS_NUM;
 
cpsw->ale = cpsw_ale_create(&ale_params);
-   if (!cpsw->ale) {
+   if (IS_ERR(cpsw->ale)) {
dev_err(dev, "error initializing ale engine\n");
-   return -ENODEV;
+   return PTR_ERR(cpsw->ale);
}
 
dma_params.dev  = dev;
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c 
b/drivers/net/ethernet/ti/netcp_ethss.c
index 9d6e27fb710e..28093923a7fb 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -3704,9 +3704,9 @@ static int gbe_probe(struct netcp_device *netcp_device, 
struct device *dev,
ale_params.nu_switch_ale = true;
}
gbe_dev->ale = cpsw_ale_create(&ale_params);
-   if (!gbe_dev->ale) {
+   if (IS_ERR(gbe_dev->ale)) {
dev_err(gbe_dev->dev, "error initializing ale engine\n");
-   ret = -ENODEV;
+   ret = PTR_ERR(gbe_dev->ale);
goto free_sec_ports;
} else {
dev_dbg(gbe_dev->dev, "Created a gbe ale engine\n");
-- 
2.20.1





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

2020-05-08 Thread Wei Yongjun
Fix to return negative error code -ENOMEM from the kzalloc() error
handling case instead of 0, as done elsewhere in this function.

Fixes: 174ab544e3bc ("nfp: abm: add cls_u32 offload for simple band 
classification")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/netronome/nfp/abm/main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/netronome/nfp/abm/main.c 
b/drivers/net/ethernet/netronome/nfp/abm/main.c
index 354efffac0f9..bdbf0726145e 100644
--- a/drivers/net/ethernet/netronome/nfp/abm/main.c
+++ b/drivers/net/ethernet/netronome/nfp/abm/main.c
@@ -333,8 +333,10 @@ nfp_abm_vnic_alloc(struct nfp_app *app, struct nfp_net 
*nn, unsigned int id)
goto err_free_alink;
 
alink->prio_map = kzalloc(abm->prio_map_len, GFP_KERNEL);
-   if (!alink->prio_map)
+   if (!alink->prio_map) {
+   err = -ENOMEM;
goto err_free_alink;
+   }
 
/* This is a multi-host app, make sure MAC/PHY is up, but don't
 * make the MAC/PHY state follow the state of any of the ports.





[PATCH net-next] octeontx2-vf: Fix error return code in otx2vf_probe()

2020-05-07 Thread Wei Yongjun
Fix to return negative error code -ENOMEM from the alloc failed error
handling case instead of 0, as done elsewhere in this function.

Fixes: 3184fb5ba96e ("octeontx2-vf: Virtual function driver support")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c 
b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
index 187c633a7af5..f4227517dc8e 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c
@@ -497,13 +497,17 @@ static int otx2vf_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
 
hw->irq_name = devm_kmalloc_array(&hw->pdev->dev, num_vec, NAME_SIZE,
  GFP_KERNEL);
-   if (!hw->irq_name)
+   if (!hw->irq_name) {
+   err = -ENOMEM;
goto err_free_netdev;
+   }
 
hw->affinity_mask = devm_kcalloc(&hw->pdev->dev, num_vec,
 sizeof(cpumask_var_t), GFP_KERNEL);
-   if (!hw->affinity_mask)
+   if (!hw->affinity_mask) {
+   err = -ENOMEM;
goto err_free_netdev;
+   }
 
err = pci_alloc_irq_vectors(hw->pdev, num_vec, num_vec, PCI_IRQ_MSIX);
if (err < 0) {





[PATCH net-next] net: ethernet: ti: fix error return code in am65_cpsw_nuss_probe()

2020-05-07 Thread Wei Yongjun
Fix to return negative error code -ENOMEM from the cpsw_ale_create()
error handling case instead of 0, as done elsewhere in this function.

Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth 
subsystem driver")
Reported-by: Hulk Robot 
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c 
b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index f8c589929308..066ba52f57cb 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -2065,6 +2065,7 @@ static int am65_cpsw_nuss_probe(struct platform_device 
*pdev)
common->ale = cpsw_ale_create(&ale_params);
if (!common->ale) {
dev_err(dev, "error initializing ale engine\n");
+   ret = -ENOMEM;
goto err_of_clear;
}





[PATCH -next] bpf: fix error return code in map_lookup_and_delete_elem()

2020-04-30 Thread Wei Yongjun
Fix to return negative error code -EFAULT from the copy_to_user() error
handling case instead of 0, as done elsewhere in this function.

Fixes: bd513cd08f10 ("bpf: add MAP_LOOKUP_AND_DELETE_ELEM syscall")
Signed-off-by: Wei Yongjun 
---
 kernel/bpf/syscall.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 3cea7602de78..68c22e9420fa 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1492,8 +1492,10 @@ static int map_lookup_and_delete_elem(union bpf_attr 
*attr)
if (err)
goto free_value;
 
-   if (copy_to_user(uvalue, value, value_size) != 0)
+   if (copy_to_user(uvalue, value, value_size) != 0) {
+   err = -EFAULT;
goto free_value;
+   }
 
err = 0;





[PATCH -next] ptp: ptp_ines: convert to devm_platform_ioremap_resource

2020-04-29 Thread Wei Yongjun
Use the helper function that wraps the calls to platform_get_resource()
and devm_ioremap_resource() together.

Signed-off-by: Wei Yongjun 
---
 drivers/ptp/ptp_ines.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/ptp/ptp_ines.c b/drivers/ptp/ptp_ines.c
index 52d77db39829..7711651ff19e 100644
--- a/drivers/ptp/ptp_ines.c
+++ b/drivers/ptp/ptp_ines.c
@@ -783,16 +783,10 @@ static struct mii_timestamping_ctrl ines_ctrl = {
 static int ines_ptp_ctrl_probe(struct platform_device *pld)
 {
struct ines_clock *clock;
-   struct resource *res;
void __iomem *addr;
int err = 0;
 
-   res = platform_get_resource(pld, IORESOURCE_MEM, 0);
-   if (!res) {
-   dev_err(&pld->dev, "missing memory resource\n");
-   return -EINVAL;
-   }
-   addr = devm_ioremap_resource(&pld->dev, res);
+   addr = devm_platform_ioremap_resource(pld, 0);
if (IS_ERR(addr)) {
err = PTR_ERR(addr);
goto out;





[PATCH net-next v2] drivers: net: davinci_mdio: fix potential NULL dereference in davinci_mdio_probe()

2020-04-28 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
since devm_ioremap() does not check input parameters for null.

This is detected by Coccinelle semantic patch.

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

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

Fixes: 03f66f067560 ("net: ethernet: ti: davinci_mdio: use devm_ioremap()")
Signed-off-by: Wei Yongjun 
Reviewed-by: Grygorii Strashko 
---
v1 -> v2: add fixes and reviewed-by
---
 drivers/net/ethernet/ti/davinci_mdio.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c 
b/drivers/net/ethernet/ti/davinci_mdio.c
index 38b7f6d35759..702fdc393da0 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -397,6 +397,8 @@ static int davinci_mdio_probe(struct platform_device *pdev)
data->dev = dev;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!res)
+   return -EINVAL;
data->regs = devm_ioremap(dev, res->start, resource_size(res));
if (!data->regs)
return -ENOMEM;





[PATCH net-next] net/mlx5: DR, Fix error return code in dr_domain_init_resources()

2019-09-05 Thread Wei Yongjun
Fix to return negative error code -ENOMEM from the error handling
case instead of 0, as done elsewhere in this function.

Fixes: 4ec9e7b02697 ("net/mlx5: DR, Expose steering domain functionality")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c 
b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c
index 3b9cf0bccf4d..461cc2c30538 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c
@@ -66,6 +66,7 @@ static int dr_domain_init_resources(struct mlx5dr_domain *dmn)
dmn->uar = mlx5_get_uars_page(dmn->mdev);
if (!dmn->uar) {
mlx5dr_err(dmn, "Couldn't allocate UAR\n");
+   ret = -ENOMEM;
goto clean_pd;
}
 
@@ -73,6 +74,7 @@ static int dr_domain_init_resources(struct mlx5dr_domain *dmn)
if (!dmn->ste_icm_pool) {
mlx5dr_err(dmn, "Couldn't get icm memory for %s\n",
   dev_name(dmn->mdev->device));
+   ret = -ENOMEM;
goto clean_uar;
}
 
@@ -80,6 +82,7 @@ static int dr_domain_init_resources(struct mlx5dr_domain *dmn)
if (!dmn->action_icm_pool) {
mlx5dr_err(dmn, "Couldn't get action icm memory for %s\n",
   dev_name(dmn->mdev->device));
+   ret = -ENOMEM;
goto free_ste_icm_pool;
}





[PATCH net-next] net/mlx5: DR, Remove useless set memory to zero use memset()

2019-09-05 Thread Wei Yongjun
The memory return by kzalloc() has already be set to zero, so
remove useless memset(0).

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

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c 
b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c
index ef0dea44f3b3..5df8436b2ae3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c
@@ -899,7 +899,6 @@ int mlx5dr_send_ring_alloc(struct mlx5dr_domain *dmn)
goto clean_qp;
}
 
-   memset(dmn->send_ring->buf, 0, size);
dmn->send_ring->buf_size = size;
 
dmn->send_ring->mr = dr_reg_mr(dmn->mdev,





[PATCH -next v2] btf: fix return value check in btf_vmlinux_init()

2019-08-15 Thread Wei Yongjun
In case of error, the function kobject_create_and_add() returns NULL
pointer not ERR_PTR(). The IS_ERR() test in the return value check
should be replaced with NULL test.

Fixes: 341dfcf8d78e ("btf: expose BTF info through sysfs")
Signed-off-by: Wei Yongjun 
Acked-by: Andrii Nakryiko 
---
 kernel/bpf/sysfs_btf.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/kernel/bpf/sysfs_btf.c b/kernel/bpf/sysfs_btf.c
index 4659349fc795..7ae51fe6 100644
--- a/kernel/bpf/sysfs_btf.c
+++ b/kernel/bpf/sysfs_btf.c
@@ -30,17 +30,12 @@ static struct kobject *btf_kobj;
 
 static int __init btf_vmlinux_init(void)
 {
-   int err;
-
if (!_binary__btf_vmlinux_bin_start)
return 0;
 
btf_kobj = kobject_create_and_add("btf", kernel_kobj);
-   if (IS_ERR(btf_kobj)) {
-   err = PTR_ERR(btf_kobj);
-   btf_kobj = NULL;
-   return err;
-   }
+   if (!btf_kobj)
+   return -ENOMEM;
 
bin_attr_btf_vmlinux.size = _binary__btf_vmlinux_bin_end -
_binary__btf_vmlinux_bin_start;





[PATCH -next] btf: fix return value check in btf_vmlinux_init()

2019-08-15 Thread Wei Yongjun
In case of error, the function kobject_create_and_add() returns NULL
pointer not ERR_PTR(). The IS_ERR() test in the return value check
should be replaced with NULL test.

Fixes: 341dfcf8d78e ("btf: expose BTF info through sysfs")
Signed-off-by: Wei Yongjun 
---
 kernel/bpf/sysfs_btf.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/kernel/bpf/sysfs_btf.c b/kernel/bpf/sysfs_btf.c
index 4659349fc795..be5557deb958 100644
--- a/kernel/bpf/sysfs_btf.c
+++ b/kernel/bpf/sysfs_btf.c
@@ -30,16 +30,13 @@ static struct kobject *btf_kobj;
 
 static int __init btf_vmlinux_init(void)
 {
-   int err;
-
if (!_binary__btf_vmlinux_bin_start)
return 0;
 
btf_kobj = kobject_create_and_add("btf", kernel_kobj);
-   if (IS_ERR(btf_kobj)) {
-   err = PTR_ERR(btf_kobj);
+   if (!btf_kobj) {
btf_kobj = NULL;
-   return err;
+   return -ENOMEM;
}
 
bin_attr_btf_vmlinux.size = _binary__btf_vmlinux_bin_end -





[PATCH v2] ag71xx: fix return value check in ag71xx_probe()

2019-07-18 Thread Wei Yongjun
In case of error, the function of_get_mac_address() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().

Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
Signed-off-by: Wei Yongjun 
Reviewed-by: Oleksij Rempel 
---
v1 -> v2: fix subsystem prefix
---
 drivers/net/ethernet/atheros/ag71xx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/atheros/ag71xx.c 
b/drivers/net/ethernet/atheros/ag71xx.c
index 72a57c6cd254..3088a43e6436 100644
--- a/drivers/net/ethernet/atheros/ag71xx.c
+++ b/drivers/net/ethernet/atheros/ag71xx.c
@@ -1732,9 +1732,9 @@ static int ag71xx_probe(struct platform_device *pdev)
ag->stop_desc->next = (u32)ag->stop_desc_dma;
 
mac_addr = of_get_mac_address(np);
-   if (mac_addr)
+   if (!IS_ERR(mac_addr))
memcpy(ndev->dev_addr, mac_addr, ETH_ALEN);
-   if (!mac_addr || !is_valid_ether_addr(ndev->dev_addr)) {
+   if (IS_ERR(mac_addr) || !is_valid_ether_addr(ndev->dev_addr)) {
netif_err(ag, probe, ndev, "invalid MAC address, using random 
address\n");
eth_random_addr(ndev->dev_addr);
}





[PATCH v2] ag71xx: fix error return code in ag71xx_probe()

2019-07-18 Thread Wei Yongjun
Fix to return error code -ENOMEM from the dmam_alloc_coherent() error
handling case instead of 0, as done elsewhere in this function.

Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
Signed-off-by: Wei Yongjun 
Reviewed-by: Oleksij Rempel 
---
v1 -> v2: fix subsystem prefix
---
 drivers/net/ethernet/atheros/ag71xx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/atheros/ag71xx.c 
b/drivers/net/ethernet/atheros/ag71xx.c
index 72a57c6cd254..446d62e93439 100644
--- a/drivers/net/ethernet/atheros/ag71xx.c
+++ b/drivers/net/ethernet/atheros/ag71xx.c
@@ -1724,8 +1724,10 @@ static int ag71xx_probe(struct platform_device *pdev)
ag->stop_desc = dmam_alloc_coherent(&pdev->dev,
sizeof(struct ag71xx_desc),
&ag->stop_desc_dma, GFP_KERNEL);
-   if (!ag->stop_desc)
+   if (!ag->stop_desc) {
+   err = -ENOMEM;
goto err_free;
+   }
 
ag->stop_desc->data = 0;
ag->stop_desc->ctrl = 0;





[PATCH] net: ethernet: fix error return code in ag71xx_probe()

2019-07-17 Thread Wei Yongjun
Fix to return error code -ENOMEM from the dmam_alloc_coherent() error
handling case instead of 0, as done elsewhere in this function.

Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/atheros/ag71xx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/atheros/ag71xx.c 
b/drivers/net/ethernet/atheros/ag71xx.c
index 72a57c6cd254..446d62e93439 100644
--- a/drivers/net/ethernet/atheros/ag71xx.c
+++ b/drivers/net/ethernet/atheros/ag71xx.c
@@ -1724,8 +1724,10 @@ static int ag71xx_probe(struct platform_device *pdev)
ag->stop_desc = dmam_alloc_coherent(&pdev->dev,
sizeof(struct ag71xx_desc),
&ag->stop_desc_dma, GFP_KERNEL);
-   if (!ag->stop_desc)
+   if (!ag->stop_desc) {
+   err = -ENOMEM;
goto err_free;
+   }
 
ag->stop_desc->data = 0;
ag->stop_desc->ctrl = 0;





[PATCH] net: ag71xx: fix return value check in ag71xx_probe()

2019-07-17 Thread Wei Yongjun
In case of error, the function of_get_mac_address() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().

Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/atheros/ag71xx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/atheros/ag71xx.c 
b/drivers/net/ethernet/atheros/ag71xx.c
index 72a57c6cd254..3088a43e6436 100644
--- a/drivers/net/ethernet/atheros/ag71xx.c
+++ b/drivers/net/ethernet/atheros/ag71xx.c
@@ -1732,9 +1732,9 @@ static int ag71xx_probe(struct platform_device *pdev)
ag->stop_desc->next = (u32)ag->stop_desc_dma;
 
mac_addr = of_get_mac_address(np);
-   if (mac_addr)
+   if (!IS_ERR(mac_addr))
memcpy(ndev->dev_addr, mac_addr, ETH_ALEN);
-   if (!mac_addr || !is_valid_ether_addr(ndev->dev_addr)) {
+   if (IS_ERR(mac_addr) || !is_valid_ether_addr(ndev->dev_addr)) {
netif_err(ag, probe, ndev, "invalid MAC address, using random 
address\n");
eth_random_addr(ndev->dev_addr);
}





[PATCH] net: dsa: sja1105: Fix missing unlock on error in sk_buff()

2019-07-16 Thread Wei Yongjun
Add the missing unlock before return from function sk_buff()
in the error handling case.

Fixes: f3097be21bf1 ("net: dsa: sja1105: Add a state machine for RX 
timestamping")
Signed-off-by: Wei Yongjun 
---
 net/dsa/tag_sja1105.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c
index 1d96c9d4a8e9..26363d72d25b 100644
--- a/net/dsa/tag_sja1105.c
+++ b/net/dsa/tag_sja1105.c
@@ -216,6 +216,7 @@ static struct sk_buff
if (!skb) {
dev_err_ratelimited(dp->ds->dev,
"Failed to copy stampable skb\n");
+   spin_unlock(&sp->data->meta_lock);
return NULL;
}
sja1105_transfer_meta(skb, meta);





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

2019-07-05 Thread Wei Yongjun
Fix to return negative error code -EINVAL from the error handling
case instead of 0, as done elsewhere in this function.

Fixes: 1f35a56cf586 ("nfp: tls: add/delete TLS TX connections")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/netronome/nfp/crypto/tls.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/netronome/nfp/crypto/tls.c 
b/drivers/net/ethernet/netronome/nfp/crypto/tls.c
index 3ee829d69c04..9f7ccb7da417 100644
--- a/drivers/net/ethernet/netronome/nfp/crypto/tls.c
+++ b/drivers/net/ethernet/netronome/nfp/crypto/tls.c
@@ -344,6 +344,7 @@ nfp_net_tls_add(struct net_device *netdev, struct sock *sk,
 
if (!reply->handle[0] && !reply->handle[1]) {
nn_dp_warn(&nn->dp, "FW returned NULL handle\n");
+   err = -EINVAL;
goto err_fw_remove;
}





[PATCH net-next] gve: Fix error return code in gve_alloc_qpls()

2019-07-04 Thread Wei Yongjun
Fix to return a negative error code from the error handling
case instead of 0, as done elsewhere in this function.

Fixes: f5cedc84a30d ("gve: Add transmit and receive support")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/google/gve/gve_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/google/gve/gve_main.c 
b/drivers/net/ethernet/google/gve/gve_main.c
index eef500bd2ff7..b65f6b010a82 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -625,8 +625,10 @@ static int gve_alloc_qpls(struct gve_priv *priv)
 sizeof(unsigned long) * BITS_PER_BYTE;
priv->qpl_cfg.qpl_id_map = kvzalloc(BITS_TO_LONGS(num_qpls) *
sizeof(unsigned long), GFP_KERNEL);
-   if (!priv->qpl_cfg.qpl_id_map)
+   if (!priv->qpl_cfg.qpl_id_map) {
+   err = -ENOMEM;
goto free_qpls;
+   }
 
return 0;





[PATCH net-next] drivers: net: davinci_mdio: fix return value check in davinci_mdio_probe()

2019-05-03 Thread Wei Yongjun
In case of error, the function devm_ioremap() returns NULL pointer not
ERR_PTR(). The IS_ERR() test in the return value check should be
replaced with NULL test.

Fixes: 03f66f067560 ("net: ethernet: ti: davinci_mdio: use devm_ioremap()")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/ti/davinci_mdio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c 
b/drivers/net/ethernet/ti/davinci_mdio.c
index 11642721c123..38b7f6d35759 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -398,8 +398,8 @@ static int davinci_mdio_probe(struct platform_device *pdev)
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
data->regs = devm_ioremap(dev, res->start, resource_size(res));
-   if (IS_ERR(data->regs))
-   return PTR_ERR(data->regs);
+   if (!data->regs)
+   return -ENOMEM;
 
davinci_mdio_init_clk(data);





[PATCH] net: sched: using kfree_rcu() to simplify the code

2019-02-16 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 
---
 net/sched/sch_api.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 7e4d1cc..53b25b8 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -526,11 +526,6 @@ static struct qdisc_size_table *qdisc_get_stab(struct 
nlattr *opt,
return stab;
 }
 
-static void stab_kfree_rcu(struct rcu_head *head)
-{
-   kfree(container_of(head, struct qdisc_size_table, rcu));
-}
-
 void qdisc_put_stab(struct qdisc_size_table *tab)
 {
if (!tab)
@@ -538,7 +533,7 @@ void qdisc_put_stab(struct qdisc_size_table *tab)
 
if (--tab->refcnt == 0) {
list_del(&tab->list);
-   call_rcu(&tab->rcu, stab_kfree_rcu);
+   kfree_rcu(tab, rcu);
}
 }
 EXPORT_SYMBOL(qdisc_put_stab);







[PATCH net-next] net: hns3: make function hclge_set_all_vf_rst() static

2019-02-16 Thread Wei Yongjun
Fixes the following sparse warning:

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c:2431:5: warning:
 symbol 'hclge_set_all_vf_rst' was not declared. Should it be static?

Fixes: aa5c4f175be6 ("net: hns3: add reset handling for VF when doing PF reset")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index ab90108..362b03c 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -2428,7 +2428,7 @@ static int hclge_set_vf_rst(struct hclge_dev *hdev, int 
func_id, bool reset)
return hclge_cmd_send(&hdev->hw, &desc, 1);
 }
 
-int hclge_set_all_vf_rst(struct hclge_dev *hdev, bool reset)
+static int hclge_set_all_vf_rst(struct hclge_dev *hdev, bool reset)
 {
int i;





[PATCH net-next] netfilter: ipt_CLUSTERIP: make symbol 'cip_netdev_notifier' static

2019-02-16 Thread Wei Yongjun
Fixes the following sparse warnings:

net/ipv4/netfilter/ipt_CLUSTERIP.c:867:23: warning:
 symbol 'cip_netdev_notifier' was not declared. Should it be static?

Fixes: 5a86d68bcf02 ("netfilter: ipt_CLUSTERIP: fix deadlock in netns exit 
routine")
Signed-off-by: Wei Yongjun 
---
 net/ipv4/netfilter/ipt_CLUSTERIP.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c 
b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index b61977d..91b369b 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -864,7 +864,7 @@ static void clusterip_net_exit(struct net *net)
.size = sizeof(struct clusterip_net),
 };
 
-struct notifier_block cip_netdev_notifier = {
+static struct notifier_block cip_netdev_notifier = {
.notifier_call = clusterip_netdev_event
 };





[PATCH net-next] igc: Make function igc_write_rss_indir_tbl() static

2019-02-15 Thread Wei Yongjun
Fixes the following sparse warning:

drivers/net/ethernet/intel/igc/igc_ethtool.c:646:6: warning:
 symbol 'igc_write_rss_indir_tbl' was not declared. Should it be static?

Fixes: 8c5ad0dae93c ("igc: Add ethtool support")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/intel/igc/igc_ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c 
b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index eff37a6c0afa..544239422577 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -643,7 +643,7 @@ static int igc_set_coalesce(struct net_device *netdev,
return 0;
 }
 
-void igc_write_rss_indir_tbl(struct igc_adapter *adapter)
+static void igc_write_rss_indir_tbl(struct igc_adapter *adapter)
 {
struct igc_hw *hw = &adapter->hw;
u32 reg = IGC_RETA(0);





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

2019-02-15 Thread Wei Yongjun
The function meth_init_tx_ring() is called from meth_tx_timeout(),
in which spin_lock is held, so we should use GFP_ATOMIC instead.

Fixes: 8d4c28fbc284 ("meth: pass struct device to DMA API functions")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/sgi/meth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/sgi/meth.c b/drivers/net/ethernet/sgi/meth.c
index f425ab528224..f1271402ca21 100644
--- a/drivers/net/ethernet/sgi/meth.c
+++ b/drivers/net/ethernet/sgi/meth.c
@@ -214,7 +214,7 @@ static int meth_init_tx_ring(struct meth_private *priv)
 {
/* Init TX ring */
priv->tx_ring = dma_alloc_coherent(&priv->pdev->dev,
-   TX_RING_BUFFER_SIZE, &priv->tx_ring_dma, GFP_KERNEL);
+   TX_RING_BUFFER_SIZE, &priv->tx_ring_dma, GFP_ATOMIC);
if (!priv->tx_ring)
return -ENOMEM;





[PATCH net-next] net: stmmac: Fix return value check in qcom_ethqos_probe()

2019-01-22 Thread Wei Yongjun
In case of error, the function devm_clk_get() returns ERR_PTR() and
never returns NULL. The NULL test in the return value check should be
replaced with IS_ERR().

Fixes: a7c30e62d4b8 ("net: stmmac: Add driver for Qualcomm ethqos")
Signed-off-by: Wei Yongjun 
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
index 30724bd..7ec8954 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
@@ -473,8 +473,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
ethqos->por = of_device_get_match_data(&pdev->dev);
 
ethqos->rgmii_clk = devm_clk_get(&pdev->dev, "rgmii");
-   if (!ethqos->rgmii_clk) {
-   ret = -ENOMEM;
+   if (IS_ERR(ethqos->rgmii_clk)) {
+   ret = PTR_ERR(ethqos->rgmii_clk);
goto err_mem;
}





[PATCH net-next] devlink: Fix error return code in devlink_health_buffer_prepare_skb()

2019-01-21 Thread Wei Yongjun
Fix to return a negative error code -EMSGSIZE from the error handling
case, otherwise 0 or uninitialized value may be returned.

Fixes: cb5ccfbe73b3 ("devlink: Add health buffer support")
Signed-off-by: Wei Yongjun 
---
 net/core/devlink.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 60248a5..0d4c774 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -4008,8 +4008,10 @@ void devlink_health_buffer_nest_cancel(struct 
devlink_health_buffer *buffer)
case DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE:
case DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE_ARRAY:
buffer_nlattr[i] = nla_nest_start(skb, desc->attrtype);
-   if (!buffer_nlattr[i])
+   if (!buffer_nlattr[i]) {
+   err = -EMSGSIZE;
goto nla_put_failure;
+   }
i++;
break;
case DEVLINK_ATTR_HEALTH_BUFFER_OBJECT_VALUE_DATA:





[PATCH net-next] xprtrdma: Fix error return code in rpcrdma_buffer_create()

2019-01-16 Thread Wei Yongjun
Fix to return a negative error code -ENOMEM from the error handling
case instead of 0, as done elsewhere in this function.

Fixes: 6d2d0ee27c7a ("xprtrdma: Replace rpcrdma_receive_wq with a per-xprt 
workqueue")
Signed-off-by: Wei Yongjun 
---
 net/sunrpc/xprtrdma/verbs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index 7749a2b..3dde058 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -1113,8 +1113,10 @@ struct rpcrdma_req *
WQ_MEM_RECLAIM | WQ_HIGHPRI,
0,
r_xprt->rx_xprt.address_strings[RPC_DISPLAY_ADDR]);
-   if (!buf->rb_completion_wq)
+   if (!buf->rb_completion_wq) {
+   rc = -ENOMEM;
goto out;
+   }
 
return 0;
 out:





[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(&pdev->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-26 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(&fore200e->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(&hwsim_phys_lock);
if (init) {
err = hwsim_subscribe_all_others(phy);
-   if (err < 0)
+   if (err < 0) {
+   mutex_unlock(&hwsim_phys_lock);
goto err_reg;
+   }
}
list_add_tail(&phy->list, &hwsim_phys);
mutex_unlock(&hwsim_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(&hwsim_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-27 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-24 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,
 &act_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, &netvsc_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 
---
 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 
---
 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-30 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 
---
 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 
---
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(&pdev->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 
---
 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(&cavium_ptp_driver);
-}
-
-static void __exit cavium_ptp_cleanup_module(void)
-{
-   pci_unregister_driver(&cavium_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 ");



[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 
---
 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 
---
 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 
---
 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(&pdev->dev, ae_dev);
-
-   pci_set_drvdata(pdev, NULL);
 }
 
 static struct pci_driver hns3_driver = {



  1   2   3   >