summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJiasheng Jiang <jiasheng@iscas.ac.cn>2021-12-15 17:37:31 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-12-22 11:32:44 +0300
commit9a77c02d1d2147a76bd187af1bf5a34242662d12 (patch)
tree58f5988ea4a2f2a26e003adaa432ed816f835b52 /drivers
parent0b4a5d1e15ce72f69be48f38dc0401dab890ae0f (diff)
downloadlinux-9a77c02d1d2147a76bd187af1bf5a34242662d12.tar.xz
sfc_ef100: potential dereference of null pointer
[ Upstream commit 407ecd1bd726f240123f704620d46e285ff30dd9 ] 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> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/sfc/ef100_nic.c3
1 files changed, 3 insertions, 0 deletions
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);