netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Denis Arefev <arefev@swemel.ru>
Cc: Simon Horman <simon.horman@netronome.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	oss-drivers@netronome.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org,
	trufanov@swemel.ru, vfh@swemel.ru
Subject: Re: [PATCH net v3] nfp: flower: Added pointer check and continue
Date: Tue, 22 Nov 2022 13:16:11 +0200	[thread overview]
Message-ID: <Y3yve5ld6KSj4GyU@unreal> (raw)
In-Reply-To: <20221118080317.119749-1-arefev@swemel.ru>

On Fri, Nov 18, 2022 at 11:03:17AM +0300, Denis Arefev wrote:
> Return value of a function 'kmalloc_array' is dereferenced at 
> lag_conf.c:347 without checking for null, 
> but it is usually checked for this function.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> Fixes: bb9a8d031140 ("nfp: flower: monitor and offload LAG groups")
> Signed-off-by: Denis Arefev <arefev@swemel.ru>
> ---
>  drivers/net/ethernet/netronome/nfp/flower/lag_conf.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

<...>

>  		acti_netdevs = kmalloc_array(entry->slave_cnt,
>  					     sizeof(*acti_netdevs), GFP_KERNEL);
> +		if (!acti_netdevs) {
> +			schedule_delayed_work(&lag->work, NFP_FL_LAG_DELAY);
> +			continue;

It is usually not good idea to continue after memory allocation fails.
So or add __GFP_NOWARN with a comment why it is safe to continue or bail
out from this loop.

Thanks

> +		}
>  
>  		/* Include sanity check in the loop. It may be that a bond has
>  		 * changed between processing the last notification and the
> -- 
> 2.25.1
> 

      parent reply	other threads:[~2022-11-22 11:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-18  8:03 [PATCH net v3] nfp: flower: Added pointer check and continue Denis Arefev
2022-11-18 12:43 ` Michal Swiatkowski
2022-11-22 11:16 ` Leon Romanovsky [this message]

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=Y3yve5ld6KSj4GyU@unreal \
    --to=leon@kernel.org \
    --cc=arefev@swemel.ru \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    --cc=simon.horman@netronome.com \
    --cc=trufanov@swemel.ru \
    --cc=vfh@swemel.ru \
    /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).