summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/bridge/cadence
diff options
context:
space:
mode:
authorAleksandr Mishin <amishin@t-argos.ru>2024-04-08 15:58:10 +0300
committerRobert Foss <rfoss@kernel.org>2024-04-08 18:35:41 +0300
commit935a92a1c400285545198ca2800a4c6c519c650a (patch)
tree7c8273d2667bb2bbbd9af6ed754ccc5a29c7e6b2 /drivers/gpu/drm/bridge/cadence
parent325af1bef5b984a9cd0cbd17302d4dd0ceb1f500 (diff)
downloadlinux-935a92a1c400285545198ca2800a4c6c519c650a.tar.xz
drm: bridge: cdns-mhdp8546: Fix possible null pointer dereference
In cdns_mhdp_atomic_enable(), the return value of drm_mode_duplicate() is assigned to mhdp_state->current_mode, and there is a dereference of it in drm_mode_set_name(), which will lead to a NULL pointer dereference on failure of drm_mode_duplicate(). Fix this bug add a check of mhdp_state->current_mode. Fixes: fb43aa0acdfd ("drm: bridge: Add support for Cadence MHDP8546 DPI/DP bridge") Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru> Reviewed-by: Robert Foss <rfoss@kernel.org> Signed-off-by: Robert Foss <rfoss@kernel.org> Link: https://patchwork.freedesktop.org/patch/msgid/20240408125810.21899-1-amishin@t-argos.ru
Diffstat (limited to 'drivers/gpu/drm/bridge/cadence')
-rw-r--r--drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
index e226acc5c15e..8a91ef0ae065 100644
--- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
+++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
@@ -2059,6 +2059,9 @@ static void cdns_mhdp_atomic_enable(struct drm_bridge *bridge,
mhdp_state = to_cdns_mhdp_bridge_state(new_state);
mhdp_state->current_mode = drm_mode_duplicate(bridge->dev, mode);
+ if (!mhdp_state->current_mode)
+ return;
+
drm_mode_set_name(mhdp_state->current_mode);
dev_dbg(mhdp->dev, "%s: Enabling mode %s\n", __func__, mode->name);