From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Chris Wilson <chris@chris-wilson.co.uk>,
Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Tvrtko Ursulin <tursulin@ursulin.net>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
"Frederic Weisbecker" <frederic@kernel.org>,
<intel-gfx@lists.freedesktop.org>,
<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] drm/i915/selftests: Fix error pointer vs NULL in __mock_request_alloc()
Date: Mon, 16 Jun 2025 11:01:08 -0400 [thread overview]
Message-ID: <aFAxtBT7z4XphADq@intel.com> (raw)
In-Reply-To: <aEKvMfJ63V7i-6xU@stanley.mountain>
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
>
next prev parent reply other threads:[~2025-06-16 15:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2025-06-18 16:54 ` Dan Carpenter
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=aFAxtBT7z4XphADq@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=airlied@gmail.com \
--cc=chris@chris-wilson.co.uk \
--cc=dan.carpenter@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=frederic@kernel.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tursulin@ursulin.net \
/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;
as well as URLs for NNTP newsgroup(s).