From: Markus Elfring <Markus.Elfring@web.de>
To: dri-devel@lists.freedesktop.org,
"Christian König" <christian.koenig@amd.com>,
"David Airlie" <airlied@gmail.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Nirmoy Das" <nirmoy.das@amd.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Thomas Zimmermann" <tzimmermann@suse.de>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] drm/mm: Move a variable assignment behind a condition check in DECLARE_NEXT_HOLE_ADDR()
Date: Sun, 12 Jul 2026 16:56:28 +0200 [thread overview]
Message-ID: <b9486c31-d8ea-4e93-bc5f-5a6da842af59@web.de> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 12 Jul 2026 16:48:41 +0200
The address of a data structure member was determined before
a corresponding null pointer check in the implementation of
the macro “DECLARE_NEXT_HOLE_ADDR”.
Thus avoid the risk for undefined behaviour by moving the assignment
for the variable “node” behind a condition check.
This issue was detected by using the Coccinelle software.
Fixes: 5fad79fd66ff90b8c0a95319dad0b099008f8347 ("drm/mm: cleanup and improve next_hole_*_addr()")
Cc: stable@vger.kernel.org
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/gpu/drm/drm_mm.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index 6692abe564d3..9b9bece8da7d 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -390,9 +390,13 @@ first_hole(struct drm_mm *mm,
#define DECLARE_NEXT_HOLE_ADDR(name, first, last) \
static struct drm_mm_node *name(struct drm_mm_node *entry, u64 size) \
{ \
- struct rb_node *parent, *node = &entry->rb_hole_addr; \
+ struct rb_node *parent, *node; \
\
- if (!entry || RB_EMPTY_NODE(node)) \
+ if (!entry) \
+ return NULL; \
+ \
+ node = &entry->rb_hole_addr; \
+ if (RB_EMPTY_NODE(node)) \
return NULL; \
\
if (usable_hole_addr(node->first, size)) { \
--
2.55.0
reply other threads:[~2026-07-12 14:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=b9486c31-d8ea-4e93-bc5f-5a6da842af59@web.de \
--to=markus.elfring@web.de \
--cc=airlied@gmail.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nirmoy.das@amd.com \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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