diff mbox series

[v2] sfc_ef100: potential dereference of null pointer

Message ID 20211215143731.188026-1-jiasheng@iscas.ac.cn (mailing list archive)
State Accepted
Commit 407ecd1bd726f240123f704620d46e285ff30dd9
Delegated to: Netdev Maintainers
Headers show
Series [v2] sfc_ef100: potential dereference of null pointer | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Jiasheng Jiang Dec. 15, 2021, 2:37 p.m. UTC
The return value of kmalloc() needs to be checked.
To avoid use in efx_nic_update_stats() in case of the failure of alloc.

Fixes: b593b6f1b492 ("sfc_ef100: statistics gathering")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reported-by: kernel test robot <lkp@intel.com>
---
Changelog:

v1 -> v2

*Change 1. Change the place to check, avoiding the warning.
---
 drivers/net/ethernet/sfc/ef100_nic.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

patchwork-bot+netdevbpf@kernel.org Dec. 16, 2021, 8:51 p.m. UTC | #1
Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Wed, 15 Dec 2021 22:37:31 +0800 you wrote:
> The return value of kmalloc() needs to be checked.
> To avoid use in efx_nic_update_stats() in case of the failure of alloc.
> 
> Fixes: b593b6f1b492 ("sfc_ef100: statistics gathering")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> Reported-by: kernel test robot <lkp@intel.com>
> 
> [...]

Here is the summary with links:
  - [v2] sfc_ef100: potential dereference of null pointer
    https://git.kernel.org/netdev/net/c/407ecd1bd726

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c
index 518268ce2064..d35cafd422b1 100644
--- a/drivers/net/ethernet/sfc/ef100_nic.c
+++ b/drivers/net/ethernet/sfc/ef100_nic.c
@@ -609,6 +609,9 @@  static size_t ef100_update_stats(struct efx_nic *efx,
 	ef100_common_stat_mask(mask);
 	ef100_ethtool_stat_mask(mask);
 
+	if (!mc_stats)
+		return 0;
+
 	efx_nic_copy_stats(efx, mc_stats);
 	efx_nic_update_stats(ef100_stat_desc, EF100_STAT_COUNT, mask,
 			     stats, mc_stats, false);