Linux CXL
 help / color / mirror / Atom feed
From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>
Cc: "Williams, Dan J" <dan.j.williams@intel.com>,
	"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>
Subject: Re: [ndctl PATCH 1/3] cxl/region: fix a dereferecnce after NULL check
Date: Tue, 23 Aug 2022 07:27:35 +0000	[thread overview]
Message-ID: <b0f9fefbad1ab051bd1b458bac84221792de7dcb.camel@intel.com> (raw)
In-Reply-To: <20220823072106.398076-2-vishal.l.verma@intel.com>

On Tue, 2022-08-23 at 01:21 -0600, Vishal Verma wrote:
> A NULL check in region_action() implies that 'decoder' might be NULL, but
> later we dereference it during cxl_decoder_foreach().
> 
> Since cxl_decoder_foreach() won't ever enter the loop with a NULL decoder,
> the check was superfluous. Remove it.
> 
> Cc: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> ---
>  cxl/region.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/cxl/region.c b/cxl/region.c
> index a30313c..9372d6b 100644
> --- a/cxl/region.c
> +++ b/cxl/region.c
> @@ -688,8 +688,6 @@ static int region_action(int argc, const char **argv, struct cxl_ctx *ctx,
>                 cxl_decoder_foreach (port, decoder) {
>                         decoder = util_cxl_decoder_filter(decoder,
>                                                           param.root_decoder);
> -                       if (!decoder)
> -                               continue;

Hm, this is actually wrong. We need to save the filter results in a new
variable, and NULL check that, while keeping the original 'decoder'
variable intact for the loop. I'll send v2.

>                         rc = decoder_region_action(p, decoder, action, count);
>                         if (rc)
>                                 err_rc = rc;


  reply	other threads:[~2022-08-23  7:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23  7:21 [ndctl PATCH 0/3] cxl: static analysis fixes Vishal Verma
2022-08-23  7:21 ` [ndctl PATCH 1/3] cxl/region: fix a dereferecnce after NULL check Vishal Verma
2022-08-23  7:27   ` Verma, Vishal L [this message]
2022-08-23  7:21 ` [ndctl PATCH 2/3] libcxl: fox a resource leak and a forward " Vishal Verma
2022-08-23  7:21 ` [ndctl PATCH 3/3] cxl/filter: Fix an uninitialized pointer dereference Vishal Verma

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=b0f9fefbad1ab051bd1b458bac84221792de7dcb.camel@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    /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