From: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Dave Stevenson <dave.stevenson@raspberrypi.com>,
Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: kernel@collabora.com, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Subject: [PATCH v2 1/2] drm/connector: hdmi: Handle NULL display mode in state check helper
Date: Thu, 09 Jan 2025 00:03:39 +0200 [thread overview]
Message-ID: <20250109-hdmi-conn-null-mode-v2-1-9eeaf1109547@collabora.com> (raw)
In-Reply-To: <20250109-hdmi-conn-null-mode-v2-0-9eeaf1109547@collabora.com>
drm_atomic_helper_connector_hdmi_check() helper makes use of
connector_state_get_mode() to obtain a drm_display_mode pointer, but it
doesn't validate it, which may lead to a NULL pointer dereference in
some cases, i.e. unloading a DRM module:
[ 1002.910414] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
[...]
[ 1002.923833] Hardware name: Radxa ROCK 5B (DT)
[ 1002.924819] pc : drm_match_cea_mode+0x30/0x280 [drm]
[ 1002.925318] lr : hdmi_try_format_bpc+0x7c/0x580 [drm_display_helper]
[...]
[ 1002.932411] Call trace:
[ 1002.932626] drm_match_cea_mode+0x30/0x280 [drm] (P)
[ 1002.933120] hdmi_try_format_bpc+0x7c/0x580 [drm_display_helper]
[ 1002.933662] drm_atomic_helper_connector_hdmi_check+0x10c/0x478 [drm_display_helper]
[ 1002.934355] drm_bridge_connector_atomic_check+0x20/0x40 [drm_display_helper]
[ 1002.934993] drm_atomic_helper_check_modeset+0x698/0xd28 [drm_kms_helper]
[ 1002.935607] drm_atomic_helper_check+0x28/0xb8 [drm_kms_helper]
[ 1002.936143] drm_atomic_check_only+0x794/0x988 [drm]
[ 1002.936635] drm_atomic_commit+0x60/0xe0 [drm]
[ 1002.937082] drm_atomic_helper_disable_all+0x184/0x218 [drm_kms_helper]
[ 1002.937678] drm_atomic_helper_shutdown+0x90/0x150 [drm_kms_helper]
[ 1002.938243] rockchip_drm_unbind+0x38/0x80 [rockchipdrm]
[ 1002.938720] component_master_del+0xac/0xf8
[ 1002.939089] rockchip_drm_platform_remove+0x34/0x78 [rockchipdrm]
[...]
Add the missing NULL check before passing the mode pointer further.
Fixes: f035f4097f1e ("drm/connector: hdmi: Calculate TMDS character rate")
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/gpu/drm/display/drm_hdmi_state_helper.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
index cfc2aaee1da08a103cbf933c891d5cc31b0886a8..e4d4fce6ab59d37067327d3e6da235c9a5a45b42 100644
--- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
+++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
@@ -503,6 +503,9 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector,
connector_state_get_mode(new_conn_state);
int ret;
+ if (!mode)
+ return 0;
+
new_conn_state->hdmi.is_limited_range = hdmi_is_limited_range(connector, new_conn_state);
ret = hdmi_compute_config(connector, new_conn_state, mode);
--
2.47.1
next prev parent reply other threads:[~2025-01-08 22:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-08 22:03 [PATCH v2 0/2] Fixup drm_atomic_helper_connector_hdmi_check() Cristian Ciocaltea
2025-01-08 22:03 ` Cristian Ciocaltea [this message]
2025-01-08 22:03 ` [PATCH v2 2/2] drm/tests: hdmi: Add connector's CRTC deactivation tests Cristian Ciocaltea
2025-01-14 17:41 ` Maxime Ripard
2025-01-14 17:58 ` Cristian Ciocaltea
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=20250109-hdmi-conn-null-mode-v2-1-9eeaf1109547@collabora.com \
--to=cristian.ciocaltea@collabora.com \
--cc=airlied@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=dave.stevenson@raspberrypi.com \
--cc=dmitry.baryshkov@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--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
all inboxes | Powered by JetHome®