lkml.org 
[lkml]   [2019]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] sfc: should check the return value after allocating memory
Date
kcalloc may fails to allocate memory, hence if it is in that case,
We should drop out in time.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
drivers/net/ethernet/sfc/efx.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
index 2fef740..712380a 100644
--- a/drivers/net/ethernet/sfc/efx.c
+++ b/drivers/net/ethernet/sfc/efx.c
@@ -3040,6 +3040,8 @@ static int efx_init_struct(struct efx_nic *efx,
/* Failure to allocate is not fatal, but may degrade ARFS performance */
efx->rps_hash_table = kcalloc(EFX_ARFS_HASH_TABLE_SIZE,
sizeof(*efx->rps_hash_table), GFP_KERNEL);
+ if (!efx->rps_hash_table)
+ goto fail;
#endif
efx->phy_op = &efx_dummy_phy_operations;
efx->mdio.dev = net_dev;
--
1.7.12.4
\
 
 \ /
  Last update: 2019-10-30 10:17    [W:0.025 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site