From: Colin Ian King <colin.i.king@gmail.com>
To: "Anitha Chrisanthus" <anitha.chrisanthus@intel.com>,
"Edmund Dea" <edmund.j.dea@intel.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"Maxime Ripard" <mripard@kernel.org>,
"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
dri-devel@lists.freedesktop.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][next] drm/kmb: Fix dereference of pointer plane before a null check
Date: Wed, 30 Jul 2025 14:34:57 +0100 [thread overview]
Message-ID: <20250730133457.2076784-1-colin.i.king@gmail.com> (raw)
Currently pointer plane is being dereferenced on the calls to
drm_atomic_get_old_plane_state and drm_atomic_get_new_plane_state
when assigning old_plane_state and new_plane_state, this could
lead to a null pointer dereference. Fix this by first performing
a null pointer check on plane, then assigning old_plane_state and
new_plance_state and then null pointer checking these.
Fixes: 977697e20b3d ("drm/atomic: Pass the full state to planes atomic disable and update")
Fixes: 37418bf14c13 ("drm: Use state helper instead of the plane state pointer")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
drivers/gpu/drm/kmb/kmb_plane.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/kmb/kmb_plane.c b/drivers/gpu/drm/kmb/kmb_plane.c
index 9e0562aa2bcb..07498deba1b6 100644
--- a/drivers/gpu/drm/kmb/kmb_plane.c
+++ b/drivers/gpu/drm/kmb/kmb_plane.c
@@ -341,10 +341,8 @@ static void kmb_plane_set_alpha(struct kmb_drm_private *kmb,
static void kmb_plane_atomic_update(struct drm_plane *plane,
struct drm_atomic_state *state)
{
- struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state,
- plane);
- struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
- plane);
+ struct drm_plane_state *old_plane_state;
+ struct drm_plane_state *new_plane_state;
struct drm_framebuffer *fb;
struct kmb_drm_private *kmb;
unsigned int width;
@@ -359,7 +357,12 @@ static void kmb_plane_atomic_update(struct drm_plane *plane,
static dma_addr_t addr[MAX_SUB_PLANES];
struct disp_cfg *init_disp_cfg;
- if (!plane || !new_plane_state || !old_plane_state)
+ if (!plane)
+ return;
+
+ old_plane_state = drm_atomic_get_old_plane_state(state, plane);
+ new_plane_state = drm_atomic_get_new_plane_state(state, plane);
+ if (!old_plane_state || !new_plane_state)
return;
fb = new_plane_state->fb;
--
2.50.0
next reply other threads:[~2025-07-30 13:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-30 13:34 Colin Ian King [this message]
2025-07-30 13:53 ` Daniel Stone
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=20250730133457.2076784-1-colin.i.king@gmail.com \
--to=colin.i.king@gmail.com \
--cc=airlied@gmail.com \
--cc=anitha.chrisanthus@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=edmund.j.dea@intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
--cc=ville.syrjala@linux.intel.com \
/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
all inboxes | Powered by JetHome®