48 lines
1.7 KiB
Diff
48 lines
1.7 KiB
Diff
From 2d2fcd6c83bbc174d1ae178388e7ae0d8297da56 Mon Sep 17 00:00:00 2001
|
||
From: Alan Coopersmith <alan.coopersmith@oracle.com>
|
||
Date: Sat, 4 Oct 2025 15:40:22 -0700
|
||
Subject: [PATCH xserver 07/51] Xext/sync: avoid null dereference in
|
||
init_system_idle_counter()
|
||
MIME-Version: 1.0
|
||
Content-Type: text/plain; charset=UTF-8
|
||
Content-Transfer-Encoding: 8bit
|
||
|
||
Reported in #1817:
|
||
|
||
xwayland-24.1.6/redhat-linux-build/../Xext/sync.c:2835:33: acquire_memory: this call could return NULL
|
||
xwayland-24.1.6/redhat-linux-build/../Xext/sync.c:2837:28: danger: ‘priv’ could be NULL: unchecked value from [(30)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/29)
|
||
# 2835| IdleCounterPriv *priv = malloc(sizeof(IdleCounterPriv));
|
||
# 2836|
|
||
# 2837|-> priv->value_less = priv->value_greater = NULL;
|
||
# 2838| priv->deviceid = deviceid;
|
||
# 2839|
|
||
|
||
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
|
||
(cherry picked from commit 304d21854d349b21dd8deb8a8f319637f17bd4a8)
|
||
|
||
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2077>
|
||
---
|
||
Xext/sync.c | 6 ++++--
|
||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||
|
||
diff --git a/Xext/sync.c b/Xext/sync.c
|
||
index 09a14ac3c..8fd7e947e 100644
|
||
--- a/Xext/sync.c
|
||
+++ b/Xext/sync.c
|
||
@@ -2876,8 +2876,10 @@ init_system_idle_counter(const char *name, int deviceid)
|
||
if (idle_time_counter != NULL) {
|
||
IdleCounterPriv *priv = malloc(sizeof(IdleCounterPriv));
|
||
|
||
- priv->value_less = priv->value_greater = NULL;
|
||
- priv->deviceid = deviceid;
|
||
+ if (priv) {
|
||
+ priv->value_less = priv->value_greater = NULL;
|
||
+ priv->deviceid = deviceid;
|
||
+ }
|
||
|
||
idle_time_counter->pSysCounterInfo->private = priv;
|
||
}
|
||
--
|
||
2.54.0
|
||
|