Linux CXL
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: <linux-cxl@vger.kernel.org>, Dave Jiang <dave.jiang@intel.com>
Subject: Re: [PATCH] cxl/hdm: Avoid NULL deref when component registers are missing
Date: Thu, 30 Mar 2023 20:04:06 +0100	[thread overview]
Message-ID: <20230330200406.00002a54@Huawei.com> (raw)
In-Reply-To: <6425d9b6bf502_c722294db@dwillia2-mobl3.amr.corp.intel.com.notmuch>

On Thu, 30 Mar 2023 11:49:26 -0700
Dan Williams <dan.j.williams@intel.com> wrote:

> Jonathan Cameron wrote:
> > On Thu, 30 Mar 2023 11:19:42 -0700
> > Dan Williams <dan.j.williams@intel.com> wrote:
> >   
> > > Jonathan Cameron wrote:  
> > > > On Wed, 29 Mar 2023 14:35:43 -0700
> > > > Dan Williams <dan.j.williams@intel.com> wrote:
> > > >     
> > > > > The cxl_port driver attempts to support endpoint devices that do not
> > > > > advertise a component register block, but by inspection
> > > > > devm_cxl_setup_hdm() passes a NULL @crb to helper functions that should
> > > > > be skipped.
> > > > > 
> > > > > Return early and skip setting target_count since that is only relevant
> > > > > for switch decoders, not endpoint decoders.    
> > > > 
> > > > This is a good observation. It would be nice to not read it for the
> > > > HDM decoder path either. Obviously we don't use it so that doesn't do
> > > > any harm, but to someone reading the code it looks like we care about the
> > > > value.  I'm not immediately sure how we'd establish at this layer that
> > > > the HDM decoder is a switch or HB one though..    
> > > 
> > > @info is NULL when this routine is called for non-endpoint decoders.  
> > 
> > Ah, so we could pass a flag into parse_hdm_decoder_caps() and not read
> > the value if it has no meaning for the particular decoder.  
> 
> How about kerneldoc on 'struct cxl_hdm' clarifying @target_count and
> other fields, because I don't see the benefit of logic to skip parsing
> that field. The overhead of an MMIO cycle to read the capability
> register has already been spent.
> 

Ok. I guess it's harmless even it if gains meaning in some later spec
version as we don't use it for anything.

Jonathan

      reply	other threads:[~2023-03-30 19:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-29 21:35 [PATCH] cxl/hdm: Avoid NULL deref when component registers are missing Dan Williams
2023-03-29 23:59 ` Dave Jiang
2023-03-30 17:19 ` Jonathan Cameron
2023-03-30 18:19   ` Dan Williams
2023-03-30 18:27     ` Jonathan Cameron
2023-03-30 18:49       ` Dan Williams
2023-03-30 19:04         ` Jonathan Cameron [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=20230330200406.00002a54@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    /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