All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Vishal Verma <vishal.l.verma@intel.com>
Cc: <linux-cxl@vger.kernel.org>, <nvdimm@lists.linux.dev>,
	Dan Williams <dan.j.williams@intel.com>
Subject: Re: [ndctl PATCH v2 1/3] cxl/region: fix a dereferecnce after NULL check
Date: Wed, 24 Aug 2022 10:30:55 +0100	[thread overview]
Message-ID: <20220824103055.0000056f@huawei.com> (raw)
In-Reply-To: <20220823074527.404435-2-vishal.l.verma@intel.com>

On Tue, 23 Aug 2022 01:45:25 -0600
Vishal Verma <vishal.l.verma@intel.com> wrote:

> A NULL check in region_action() implies that 'decoder' might be NULL, but
> later we dereference it during cxl_decoder_foreach(). The NULL check is
> valid because it was the filter result being checked, however, while
> doing this, the original 'decoder' variable was being clobbered.
> 
> Check the filter results independently of the original decoder variable.
> 
> Cc: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>

Typo in patch title.

> ---
>  cxl/region.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/cxl/region.c b/cxl/region.c
> index a30313c..334fcc2 100644
> --- a/cxl/region.c
> +++ b/cxl/region.c
> @@ -686,9 +686,8 @@ static int region_action(int argc, const char **argv, struct cxl_ctx *ctx,
>  			continue;
>  
>  		cxl_decoder_foreach (port, decoder) {
> -			decoder = util_cxl_decoder_filter(decoder,
> -							  param.root_decoder);
> -			if (!decoder)
> +			if (!util_cxl_decoder_filter(decoder,
> +						     param.root_decoder))
>  				continue;
>  			rc = decoder_region_action(p, decoder, action, count);
>  			if (rc)


  parent reply	other threads:[~2022-08-24  9:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23  7:45 [ndctl PATCH v2 0/3] cxl: static analysis fixes Vishal Verma
2022-08-23  7:45 ` [ndctl PATCH v2 1/3] cxl/region: fix a dereferecnce after NULL check Vishal Verma
2022-08-23 17:25   ` Dan Williams
2022-08-24  0:03   ` Dave Jiang
2022-08-24  9:30   ` Jonathan Cameron [this message]
2022-08-23  7:45 ` [ndctl PATCH v2 2/3] libcxl: fox a resource leak and a forward " Vishal Verma
2022-08-23 17:27   ` Dan Williams
2022-08-24  0:04   ` Dave Jiang
2022-08-23  7:45 ` [ndctl PATCH v2 3/3] cxl/filter: Fix an uninitialized pointer dereference Vishal Verma
2022-08-23 17:27   ` Dan Williams
2022-08-24  0:04   ` Dave Jiang
2022-08-24  9:37 ` [ndctl PATCH v2 0/3] cxl: static analysis fixes Jonathan Cameron

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=20220824103055.0000056f@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=vishal.l.verma@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.