* [PATCH] drm/i915/selftests: Fix error pointer vs NULL in __mock_request_alloc()
@ 2025-06-06 9:04 Dan Carpenter
2025-06-16 15:01 ` Rodrigo Vivi
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2025-06-06 9:04 UTC (permalink / raw)
To: Chris Wilson
Cc: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
David Airlie, Simona Vetter, Frederic Weisbecker, intel-gfx,
dri-devel, linux-kernel, kernel-janitors
The __mock_request_alloc() implements the smoketest->request_alloc()
function pointer. It's called from __igt_breadcrumbs_smoketest().
It's supposed to return error pointers, and returning NULL will lead to
a NULL pointer dereference.
Fixes: 52c0fdb25c7c ("drm/i915: Replace global breadcrumbs with per-context interrupt tracking")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/gpu/drm/i915/selftests/i915_request.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/selftests/i915_request.c b/drivers/gpu/drm/i915/selftests/i915_request.c
index 88870844b5bd..e349244a5fba 100644
--- a/drivers/gpu/drm/i915/selftests/i915_request.c
+++ b/drivers/gpu/drm/i915/selftests/i915_request.c
@@ -290,7 +290,12 @@ struct smoketest {
static struct i915_request *
__mock_request_alloc(struct intel_context *ce)
{
- return mock_request(ce, 0);
+ struct i915_request *rq;
+
+ rq = mock_request(ce, 0);
+ if (!rq)
+ return ERR_PTR(-ENOMEM);
+ return rq;
}
static struct i915_request *
--
2.47.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/i915/selftests: Fix error pointer vs NULL in __mock_request_alloc()
2025-06-06 9:04 [PATCH] drm/i915/selftests: Fix error pointer vs NULL in __mock_request_alloc() Dan Carpenter
@ 2025-06-16 15:01 ` Rodrigo Vivi
2025-06-18 16:54 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Rodrigo Vivi @ 2025-06-16 15:01 UTC (permalink / raw)
To: Dan Carpenter
Cc: Chris Wilson, Jani Nikula, Joonas Lahtinen, Tvrtko Ursulin,
David Airlie, Simona Vetter, Frederic Weisbecker, intel-gfx,
dri-devel, linux-kernel, kernel-janitors
On Fri, Jun 06, 2025 at 12:04:49PM +0300, Dan Carpenter wrote:
> The __mock_request_alloc() implements the smoketest->request_alloc()
> function pointer. It's called from __igt_breadcrumbs_smoketest().
> It's supposed to return error pointers, and returning NULL will lead to
> a NULL pointer dereference.
>
> Fixes: 52c0fdb25c7c ("drm/i915: Replace global breadcrumbs with per-context interrupt tracking")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/gpu/drm/i915/selftests/i915_request.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/selftests/i915_request.c b/drivers/gpu/drm/i915/selftests/i915_request.c
> index 88870844b5bd..e349244a5fba 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_request.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_request.c
> @@ -290,7 +290,12 @@ struct smoketest {
> static struct i915_request *
> __mock_request_alloc(struct intel_context *ce)
> {
> - return mock_request(ce, 0);
> + struct i915_request *rq;
> +
> + rq = mock_request(ce, 0);
> + if (!rq)
> + return ERR_PTR(-ENOMEM);
I believe we should fix mock_request and make it to stop replacing the
error per NULL, and make the callers to check for IS_ERR instead of is not NULL.
Then don't need to make up an error here.
> + return rq;
> }
>
> static struct i915_request *
> --
> 2.47.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/i915/selftests: Fix error pointer vs NULL in __mock_request_alloc()
2025-06-16 15:01 ` Rodrigo Vivi
@ 2025-06-18 16:54 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-06-18 16:54 UTC (permalink / raw)
To: Rodrigo Vivi
Cc: Chris Wilson, Jani Nikula, Joonas Lahtinen, Tvrtko Ursulin,
David Airlie, Simona Vetter, Frederic Weisbecker, intel-gfx,
dri-devel, linux-kernel, kernel-janitors
On Mon, Jun 16, 2025 at 11:01:08AM -0400, Rodrigo Vivi wrote:
> On Fri, Jun 06, 2025 at 12:04:49PM +0300, Dan Carpenter wrote:
> > --- a/drivers/gpu/drm/i915/selftests/i915_request.c
> > +++ b/drivers/gpu/drm/i915/selftests/i915_request.c
> > @@ -290,7 +290,12 @@ struct smoketest {
> > static struct i915_request *
> > __mock_request_alloc(struct intel_context *ce)
> > {
> > - return mock_request(ce, 0);
> > + struct i915_request *rq;
> > +
> > + rq = mock_request(ce, 0);
> > + if (!rq)
> > + return ERR_PTR(-ENOMEM);
>
> I believe we should fix mock_request and make it to stop replacing the
> error per NULL, and make the callers to check for IS_ERR instead of is not NULL.
>
> Then don't need to make up an error here.
>
Sure, can do.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-18 16:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-06 9:04 [PATCH] drm/i915/selftests: Fix error pointer vs NULL in __mock_request_alloc() Dan Carpenter
2025-06-16 15:01 ` Rodrigo Vivi
2025-06-18 16:54 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).