[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20211130143635.160440-1-zhou1615@umn.edu>
Date: Tue, 30 Nov 2021 22:36:35 +0800
From: Zhou Qingyang <zhou1615@....edu>
To: zhou1615@....edu
Cc: kjlu@....edu, Linus Walleij <linus.walleij@...aro.org>,
Thierry Reding <thierry.reding@...il.com>,
Sam Ravnborg <sam@...nborg.org>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH] drm/panel: Fix a NULL pointer dereference in versatile_panel_get_modes()
In versatile_panel_get_modes(), the return value of drm_mode_duplicate()
is assigned to mode and there is a dereference of it in
versatile_panel_get_modes(), which could lead to a NULL pointer
dereference on failure of drm_mode_duplicate().
Fix this bug by adding a check of mode.
This bug was found by a static analyzer. The analysis employs
differential checking to identify inconsistent security operations
(e.g., checks or kfrees) between two code paths and confirms that the
inconsistent operations are not recovered in the current function or
the callers, so they constitute bugs.
Note that, as a bug found by static analysis, it can be a false
positive or hard to trigger. Multiple researchers have cross-reviewed
the bug.
Builds with CONFIG_DRM_PANEL_ARM_VERSATILE=m show no new warnings,
and our static analyzer no longer warns about this code.
Fixes: aa6c43644bc5 ("drm/panel: drop drm_device from drm_panel")
Signed-off-by: Zhou Qingyang <zhou1615@....edu>
---
drivers/gpu/drm/panel/panel-arm-versatile.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/panel/panel-arm-versatile.c b/drivers/gpu/drm/panel/panel-arm-versatile.c
index abb0788843c6..5e73083c09a2 100644
--- a/drivers/gpu/drm/panel/panel-arm-versatile.c
+++ b/drivers/gpu/drm/panel/panel-arm-versatile.c
@@ -267,6 +267,9 @@ static int versatile_panel_get_modes(struct drm_panel *panel,
connector->display_info.bus_flags = vpanel->panel_type->bus_flags;
mode = drm_mode_duplicate(connector->dev, &vpanel->panel_type->mode);
+ if (!mode)
+ return -ENOMEM;
+
drm_mode_set_name(mode);
mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
--
2.25.1
Powered by blists - more mailing lists