* [PATCH] octeontx2-pf: Add check for devm_kcalloc
@ 2022-11-22 5:54 Jiasheng Jiang
2022-11-22 12:00 ` Maciej Fijalkowski
2022-11-24 8:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Jiasheng Jiang @ 2022-11-22 5:54 UTC (permalink / raw)
To: sgoutham, lcherian, gakula, jerinj, hkelam, sbhatta, davem,
edumazet, kuba, pabeni, richardcochran
Cc: netdev, linux-kernel, Jiasheng Jiang
As the devm_kcalloc may return NULL pointer,
it should be better to add check for the return
value, as same as the others.
Fixes: e8e095b3b370 ("octeontx2-af: cn10k: Bandwidth profiles config support")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 7646bb2ec89b..a62c1b322012 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -4985,6 +4985,8 @@ static int nix_setup_ipolicers(struct rvu *rvu,
ipolicer->ref_count = devm_kcalloc(rvu->dev,
ipolicer->band_prof.max,
sizeof(u16), GFP_KERNEL);
+ if (!ipolicer->ref_count)
+ return -ENOMEM;
}
/* Set policer timeunit to 2us ie (19 + 1) * 100 nsec = 2us */
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] octeontx2-pf: Add check for devm_kcalloc
2022-11-22 5:54 [PATCH] octeontx2-pf: Add check for devm_kcalloc Jiasheng Jiang
@ 2022-11-22 12:00 ` Maciej Fijalkowski
2022-11-24 8:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Maciej Fijalkowski @ 2022-11-22 12:00 UTC (permalink / raw)
To: Jiasheng Jiang
Cc: sgoutham, lcherian, gakula, jerinj, hkelam, sbhatta, davem,
edumazet, kuba, pabeni, richardcochran, netdev, linux-kernel
On Tue, Nov 22, 2022 at 01:54:49PM +0800, Jiasheng Jiang wrote:
> As the devm_kcalloc may return NULL pointer,
> it should be better to add check for the return
> value, as same as the others.
>
> Fixes: e8e095b3b370 ("octeontx2-af: cn10k: Bandwidth profiles config support")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> index 7646bb2ec89b..a62c1b322012 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
> @@ -4985,6 +4985,8 @@ static int nix_setup_ipolicers(struct rvu *rvu,
> ipolicer->ref_count = devm_kcalloc(rvu->dev,
> ipolicer->band_prof.max,
> sizeof(u16), GFP_KERNEL);
> + if (!ipolicer->ref_count)
> + return -ENOMEM;
So every other successful devm_kcalloc() calls in here don't have to be
explicitly freed in case of an error as in the end rvu_nix_init() will
fail and therefore the probe() itself.
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Please also remember to state which tree you are targetting your patch
(this is a fix so you should have [PATCH net])
> }
>
> /* Set policer timeunit to 2us ie (19 + 1) * 100 nsec = 2us */
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] octeontx2-pf: Add check for devm_kcalloc
2022-11-22 5:54 [PATCH] octeontx2-pf: Add check for devm_kcalloc Jiasheng Jiang
2022-11-22 12:00 ` Maciej Fijalkowski
@ 2022-11-24 8:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-11-24 8:00 UTC (permalink / raw)
To: Jiasheng Jiang
Cc: sgoutham, lcherian, gakula, jerinj, hkelam, sbhatta, davem,
edumazet, kuba, pabeni, richardcochran, netdev, linux-kernel
Hello:
This patch was applied to netdev/net.git (master)
by Paolo Abeni <pabeni@redhat.com>:
On Tue, 22 Nov 2022 13:54:49 +0800 you wrote:
> As the devm_kcalloc may return NULL pointer,
> it should be better to add check for the return
> value, as same as the others.
>
> Fixes: e8e095b3b370 ("octeontx2-af: cn10k: Bandwidth profiles config support")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
>
> [...]
Here is the summary with links:
- octeontx2-pf: Add check for devm_kcalloc
https://git.kernel.org/netdev/net/c/cd07eadd5147
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-24 8:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22 5:54 [PATCH] octeontx2-pf: Add check for devm_kcalloc Jiasheng Jiang
2022-11-22 12:00 ` Maciej Fijalkowski
2022-11-24 8:00 ` patchwork-bot+netdevbpf
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).