Skip to content

Commit 7701c8b

Browse files
committed
cxl/hdm: Fail upon detecting 0-sized decoders
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: 9c57cde ("cxl/hdm: Enumerate allocated DPA") Cc: <stable@vger.kernel.org> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Link: https://lore.kernel.org/r/168149843516.792294.11872242648319572632.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 09a9639 commit 7701c8b

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

drivers/cxl/core/hdm.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,11 @@ static int __cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled,
269269

270270
lockdep_assert_held_write(&cxl_dpa_rwsem);
271271

272-
if (!len)
273-
goto success;
272+
if (!len) {
273+
dev_warn(dev, "decoder%d.%d: empty reservation attempted\n",
274+
port->id, cxled->cxld.id);
275+
return -EINVAL;
276+
}
274277

275278
if (cxled->dpa_res) {
276279
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,
323326
cxled->mode = CXL_DECODER_MIXED;
324327
}
325328

326-
success:
327329
port->hdm_end++;
328330
get_device(&cxled->cxld.dev);
329331
return 0;
@@ -833,6 +835,13 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld,
833835
port->id, cxld->id);
834836
return -ENXIO;
835837
}
838+
839+
if (size == 0) {
840+
dev_warn(&port->dev,
841+
"decoder%d.%d: Committed with zero size\n",
842+
port->id, cxld->id);
843+
return -ENXIO;
844+
}
836845
port->commit_end = cxld->id;
837846
} else {
838847
/* unless / until type-2 drivers arrive, assume type-3 */

0 commit comments

Comments
 (0)