* [PATCH] sfc: should check the return value after allocating memory
@ 2019-10-30 9:12 zhong jiang
2019-10-30 19:12 ` Edward Cree
0 siblings, 1 reply; 2+ messages in thread
From: zhong jiang @ 2019-10-30 9:12 UTC (permalink / raw)
To: davem; +Cc: ecree, mhabets, netdev, linux-kernel, zhongjiang
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sfc: should check the return value after allocating memory
2019-10-30 9:12 [PATCH] sfc: should check the return value after allocating memory zhong jiang
@ 2019-10-30 19:12 ` Edward Cree
0 siblings, 0 replies; 2+ messages in thread
From: Edward Cree @ 2019-10-30 19:12 UTC (permalink / raw)
To: zhong jiang, davem; +Cc: mhabets, netdev, linux-kernel
On 30/10/2019 09:12, zhong jiang wrote:
> 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;
NAK.
As per the comment just above the allocation, if this allocation fails we are
able to continue (albeit with possibly reduced performance), since the code
paths that use efx->rps_hash_table all NULL-check it.
-Ed
> #endif
> efx->phy_op = &efx_dummy_phy_operations;
> efx->mdio.dev = net_dev;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-30 19:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 9:12 [PATCH] sfc: should check the return value after allocating memory zhong jiang
2019-10-30 19:12 ` Edward Cree
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).