From: Dave Jiang <dave.jiang@intel.com>
To: Dan Williams <dan.j.williams@intel.com>, linux-cxl@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: Re: [PATCH 1/5] cxl/hdm: Fail upon detecting 0-sized decoders
Date: Fri, 14 Apr 2023 14:19:50 -0700 [thread overview]
Message-ID: <7e4223af-ecdf-9677-9682-7519bb15e9a1@intel.com> (raw)
In-Reply-To: <168149843516.792294.11872242648319572632.stgit@dwillia2-xfh.jf.intel.com>
On 4/14/23 11:53 AM, Dan Williams wrote:
> Decoders committed with 0-size lead to later crashes on shutdown as
> __cxl_dpa_release() assumes a 'struct resource' has been established in
> the in 'cxlds->dpa_res'. Just fail the driver load in this instance
> since there are deeper problems with the enumeration or the setup when
> this happens.
>
> Fixes: 9c57cde0dcbd ("cxl/hdm: Enumerate allocated DPA")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> drivers/cxl/core/hdm.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
> index 02cc2c38b44b..35b338b716fe 100644
> --- a/drivers/cxl/core/hdm.c
> +++ b/drivers/cxl/core/hdm.c
> @@ -269,8 +269,11 @@ static int __cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled,
>
> lockdep_assert_held_write(&cxl_dpa_rwsem);
>
> - if (!len)
> - goto success;
> + if (!len) {
> + dev_warn(dev, "decoder%d.%d: empty reservation attempted\n",
> + port->id, cxled->cxld.id);
> + return -EINVAL;
> + }
>
> if (cxled->dpa_res) {
> dev_dbg(dev, "decoder%d.%d: existing allocation %pr assigned\n",
> @@ -323,7 +326,6 @@ static int __cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled,
> cxled->mode = CXL_DECODER_MIXED;
> }
>
> -success:
> port->hdm_end++;
> get_device(&cxled->cxld.dev);
> return 0;
> @@ -833,6 +835,13 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld,
> port->id, cxld->id);
> return -ENXIO;
> }
> +
> + if (size == 0) {
> + dev_warn(&port->dev,
> + "decoder%d.%d: Committed with zero size\n",
> + port->id, cxld->id);
> + return -ENXIO;
> + }
> port->commit_end = cxld->id;
> } else {
> /* unless / until type-2 drivers arrive, assume type-3 */
>
next prev parent reply other threads:[~2023-04-14 21:20 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-14 18:53 [PATCH 0/5] cxl/hdm: Decoder enumeration fixes Dan Williams
2023-04-14 18:53 ` [PATCH 1/5] cxl/hdm: Fail upon detecting 0-sized decoders Dan Williams
2023-04-14 20:11 ` Alison Schofield
2023-04-14 21:19 ` Dave Jiang [this message]
2023-05-15 10:38 ` Jonathan Cameron
2023-04-14 18:54 ` [PATCH 2/5] cxl/hdm: Use 4-byte reads to retrieve HDM decoder base+limit Dan Williams
2023-04-14 20:32 ` Alison Schofield
2023-04-14 20:44 ` Dan Williams
2023-04-14 21:22 ` Dave Jiang
2023-05-15 10:46 ` Jonathan Cameron
2023-04-14 18:54 ` [PATCH 3/5] cxl/core: Drop unused io-64-nonatomic-lo-hi.h Dan Williams
2023-04-14 20:33 ` Alison Schofield
2023-04-14 21:22 ` Dave Jiang
2023-05-15 10:48 ` Jonathan Cameron
2023-04-14 18:54 ` [PATCH 4/5] cxl/port: Scan single-target ports for decoders Dan Williams
2023-04-14 20:55 ` Alison Schofield
2023-04-14 21:24 ` Dave Jiang
2023-04-17 16:48 ` Jonathan Cameron
2023-04-14 18:54 ` [PATCH 5/5] cxl/hdm: Add more HDM decoder debug messages at startup Dan Williams
2023-04-14 21:06 ` Alison Schofield
2023-04-14 21:25 ` Dave Jiang
2023-05-15 10:52 ` 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=7e4223af-ecdf-9677-9682-7519bb15e9a1@intel.com \
--to=dave.jiang@intel.com \
--cc=dan.j.williams@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=stable@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