From: sashiko-bot@kernel.org
To: "Alexandru Dadu" <alexandru.dadu@imgtec.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3] drm/imagination: Fix parameter validation in pvr_fw_object_destroy()
Date: Tue, 22 Sep 2026 05:49:19 +0000 [thread overview]
Message-ID: <20260922054919.E88841F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260922-fix-null-pointer-dereference-v3-1-f099763ed676@imgtec.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/imagination: memory leak of fw_obj on allocation error path
--
commit f0dd8a6ab034ccbc4cdc49ac4cbb537593b10a6d
Author: Alexandru Dadu <alexandru.dadu@imgtec.com>
Subject: drm/imagination: Fix parameter validation in pvr_fw_object_destroy()
This patch attempts to fix a possible NULL pointer dereference in
pvr_fw_object_destroy() when handling allocation failures in
pvr_fw_object_create_and_map_common() by returning early.
Link: https://lore.kernel.org/dri-devel/20260810132202.3C16D1F000E9@smtp.kernel.org/
> diff --git a/drivers/gpu/drm/imagination/pvr_fw.c b/drivers/gpu/drm/imagination/pvr_fw.c
> index 850a3ec8e7750..9977f4da3d8d7 100644
> --- a/drivers/gpu/drm/imagination/pvr_fw.c
> +++ b/drivers/gpu/drm/imagination/pvr_fw.c
> @@ -1429,6 +1429,12 @@ void pvr_fw_object_destroy(struct pvr_fw_object *fw_obj)
> struct drm_gem_object *gem_obj = gem_from_pvr_gem(pvr_obj);
> struct pvr_device *pvr_dev = to_pvr_device(gem_obj->dev);
>
> + if (!fw_obj)
> + return;
> +
> + if (!fw_obj->gem)
> + return;
[Severity: High]
Does this code leave the original NULL pointer dereference unfixed?
Since the local variables gem_obj and pvr_dev are declared and initialized
before these new early returns, fw_obj and fw_obj->gem are implicitly
dereferenced by accessing gem_obj->dev before the check is ever reached.
If either is NULL, an oops will still occur at the start of the function.
[ ... ]
> @@ -1439,8 +1445,7 @@ void pvr_fw_object_destroy(struct pvr_fw_object *fw_obj)
> return;
> }
>
> - if (fw_obj->gem)
> - pvr_gem_object_put(fw_obj->gem);
> + pvr_gem_object_put(fw_obj->gem);
>
> kfree(fw_obj);
[Severity: High]
Could the early return added above cause a memory leak regression?
In pvr_fw_object_create_and_map_common(), if pvr_gem_object_create() fails,
fw_obj->gem is set to NULL and the error cleanup path calls
pvr_fw_object_destroy().
The new early return for !fw_obj->gem skips this kfree(fw_obj) at the end of
the function, permanently leaking the firmware object structure.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260922-fix-null-pointer-dereference-v3-1-f099763ed676@imgtec.com?part=1
prev parent reply other threads:[~2026-09-22 5:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 5:39 [PATCH v3] drm/imagination: Fix parameter validation in pvr_fw_object_destroy() Alexandru Dadu
2026-09-22 5:49 ` sashiko-bot [this message]
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=20260922054919.E88841F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexandru.dadu@imgtec.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.