DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: Shiqi Liu <835703180@qq.com>, dev@dpdk.org
Subject: Re: [PATCH] raw/ioat: Check for the NULL pointer after calling malloc
Date: Wed, 6 Jul 2022 10:05:47 +0100	[thread overview]
Message-ID: <YsVQaxCPghkoP2IM@bricha3-MOBL.ger.corp.intel.com> (raw)
In-Reply-To: <7856744.uz5P2jW1tq@thomas>

On Tue, Jul 05, 2022 at 09:43:34PM +0200, Thomas Monjalon wrote:
> 27/06/2022 19:52, 835703180@qq.com:
> > From: Shiqi Liu <835703180@qq.com>
> > 
> > As the possible failure of the malloc(), the not_checked and
> > checked could be NULL pointer.
> > Therefore, it should be better to check it in order to avoid
> > the dereference of the NULL pointer.
> > 
> > Fixes: b7aaf417f93 ("raw/ioat: add bus driver for device scanning automatically")
> > 
> > Signed-off-by: Shiqi Liu <835703180@qq.com>
> > ---
> > --- a/drivers/raw/ioat/idxd_bus.c
> > +++ b/drivers/raw/ioat/idxd_bus.c
> > @@ -301,6 +301,10 @@ dsa_scan(void)
> >  		IOAT_PMD_DEBUG("%s(): found %s/%s", __func__, path, wq->d_name);
> >  
> >  		dev = malloc(sizeof(*dev));
> > +		if (dev == NULL) {
> > +			closedir(dev_dir);
> > +			return ENOMEM;
> 
> Isn't it supposed to be a negative value?
> 
Yes, I missed that on my review. Reading the definition of what the bus
"scan" method is to return it indicates <0 on error.

/Bruce

      reply	other threads:[~2022-07-06  9:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-27 17:52 835703180
2022-07-05 10:14 ` Bruce Richardson
2022-07-05 19:43 ` Thomas Monjalon
2022-07-06  9:05   ` Bruce Richardson [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=YsVQaxCPghkoP2IM@bricha3-MOBL.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=835703180@qq.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /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).