netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Cc: <sgoutham@marvell.com>, <lcherian@marvell.com>,
	<gakula@marvell.com>, <jerinj@marvell.com>, <hkelam@marvell.com>,
	<sbhatta@marvell.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<richardcochran@gmail.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] octeontx2-pf: Add check for devm_kcalloc
Date: Tue, 22 Nov 2022 13:00:06 +0100	[thread overview]
Message-ID: <Y3y5xpewO/wh6ooB@boxer> (raw)
In-Reply-To: <20221122055449.31247-1-jiasheng@iscas.ac.cn>

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
> 

  reply	other threads:[~2022-11-22 12:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-22  5:54 [PATCH] octeontx2-pf: Add check for devm_kcalloc Jiasheng Jiang
2022-11-22 12:00 ` Maciej Fijalkowski [this message]
2022-11-24  8:00 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y3y5xpewO/wh6ooB@boxer \
    --to=maciej.fijalkowski@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gakula@marvell.com \
    --cc=hkelam@marvell.com \
    --cc=jerinj@marvell.com \
    --cc=jiasheng@iscas.ac.cn \
    --cc=kuba@kernel.org \
    --cc=lcherian@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).