* [PATCH next] cxl/region: Fix an ERR_PTR() vs NULL bug
@ 2025-07-18 21:22 Dan Carpenter
2025-07-18 23:27 ` Dave Jiang
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-07-18 21:22 UTC (permalink / raw)
To: Dan Williams
Cc: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Ira Weiny, Fabio M. De Francesco, Robert Richter,
Li Ming, Peter Zijlstra, linux-cxl, linux-kernel,
kernel-janitors
The __cxl_decoder_detach() function is expected to return NULL on error
but this error path accidentally returns an error pointer. It could
potentially lead to an error pointer dereference in the caller. Change
it to return NULL.
Fixes: b3a88225519c ("cxl/region: Consolidate cxl_decoder_kill_region() and cxl_region_detach()")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/cxl/core/region.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index f0765a0af845..71cc42d05248 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -2108,7 +2108,7 @@ __cxl_decoder_detach(struct cxl_region *cxlr,
if (pos >= p->interleave_ways) {
dev_dbg(&cxlr->dev, "position %d out of range %d\n",
pos, p->interleave_ways);
- return ERR_PTR(-ENXIO);
+ return NULL;
}
if (!p->targets[pos])
--
2.47.2
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH next] cxl/region: Fix an ERR_PTR() vs NULL bug
2025-07-18 21:22 [PATCH next] cxl/region: Fix an ERR_PTR() vs NULL bug Dan Carpenter
@ 2025-07-18 23:27 ` Dave Jiang
0 siblings, 0 replies; 2+ messages in thread
From: Dave Jiang @ 2025-07-18 23:27 UTC (permalink / raw)
To: Dan Carpenter, Dan Williams
Cc: Davidlohr Bueso, Jonathan Cameron, Alison Schofield,
Vishal Verma, Ira Weiny, Fabio M. De Francesco, Robert Richter,
Li Ming, Peter Zijlstra, linux-cxl, linux-kernel,
kernel-janitors
On 7/18/25 2:22 PM, Dan Carpenter wrote:
> The __cxl_decoder_detach() function is expected to return NULL on error
> but this error path accidentally returns an error pointer. It could
> potentially lead to an error pointer dereference in the caller. Change
> it to return NULL.
>
> Fixes: b3a88225519c ("cxl/region: Consolidate cxl_decoder_kill_region() and cxl_region_detach()")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Thanks Dan!
Applied to cxl/next
49d6e658e758e42aaff8ae5ecdd2d06b29abf53e
> ---
> drivers/cxl/core/region.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index f0765a0af845..71cc42d05248 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -2108,7 +2108,7 @@ __cxl_decoder_detach(struct cxl_region *cxlr,
> if (pos >= p->interleave_ways) {
> dev_dbg(&cxlr->dev, "position %d out of range %d\n",
> pos, p->interleave_ways);
> - return ERR_PTR(-ENXIO);
> + return NULL;
> }
>
> if (!p->targets[pos])
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-18 23:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-18 21:22 [PATCH next] cxl/region: Fix an ERR_PTR() vs NULL bug Dan Carpenter
2025-07-18 23:27 ` Dave Jiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®