mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sfc_ef100: potential dereference of null pointer
@ 2021-12-15  9:41 Jiasheng Jiang
  2021-12-15 14:03 ` kernel test robot
  2021-12-15 16:27 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Jiasheng Jiang @ 2021-12-15  9:41 UTC (permalink / raw)
  To: ecree.xilinx, habetsm.xilinx, davem, kuba
  Cc: netdev, linux-kernel, Jiasheng Jiang

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>
---
 drivers/net/ethernet/sfc/ef100_nic.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c
index 518268ce2064..ac55c6740e35 100644
--- a/drivers/net/ethernet/sfc/ef100_nic.c
+++ b/drivers/net/ethernet/sfc/ef100_nic.c
@@ -602,6 +602,9 @@ static size_t ef100_update_stats(struct efx_nic *efx,
 				 struct rtnl_link_stats64 *core_stats)
 {
 	__le64 *mc_stats = kmalloc(array_size(efx->num_mac_stats, sizeof(__le64)), GFP_ATOMIC);
+	if (!mc_stats)
+		return 0;
+
 	struct ef100_nic_data *nic_data = efx->nic_data;
 	DECLARE_BITMAP(mask, EF100_STAT_COUNT) = {};
 	u64 *stats = nic_data->stats;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-15 16:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-15  9:41 [PATCH] sfc_ef100: potential dereference of null pointer Jiasheng Jiang
2021-12-15 14:03 ` kernel test robot
2021-12-15 16:27 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®