Skip to content

Commit 852c68b

Browse files
Liu Yinglucaceresoli
authored andcommitted
drm/bridge: imx8qxp-ldb: Fix NULL pointer dereference in imx8qxp_ldb_bridge_destroy()
Pointer bridge->driver_private in imx8qxp_ldb_bridge_destroy() is NULL when a LDB channel is unavailable or imx8qxp_ldb_probe() returns error, because ldb_add_bridge_helper() is the last function called from imx8qxp_ldb_probe() and it doesn't initialize bridge->driver_private if a LDB channel is unavailable. The NULL pointer would be set to pointer ldb_ch and then NULL pointer ldb_ch would be dereferenced. Fix this by returning early from imx8qxp_ldb_bridge_destroy() if !ldb_ch is true. Fixes: 32529d3 ("drm/bridge: imx8qxp-ldb: convert to of_drm_find_and_get_bridge()") Signed-off-by: Liu Ying <victor.liu@nxp.com> Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20260123-imx8qxp-drm-bridge-fixes-v1-1-8bb85ada5866@nxp.com Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
1 parent 474d540 commit 852c68b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@ static inline struct imx8qxp_ldb *base_to_imx8qxp_ldb(struct ldb *base)
6565
static void imx8qxp_ldb_bridge_destroy(struct drm_bridge *bridge)
6666
{
6767
struct ldb_channel *ldb_ch = bridge->driver_private;
68-
struct ldb *ldb = ldb_ch->ldb;
69-
struct imx8qxp_ldb *imx8qxp_ldb = base_to_imx8qxp_ldb(ldb);
68+
struct imx8qxp_ldb *imx8qxp_ldb;
69+
70+
if (!ldb_ch)
71+
return;
7072

73+
imx8qxp_ldb = base_to_imx8qxp_ldb(ldb_ch->ldb);
7174
drm_bridge_put(imx8qxp_ldb->companion);
7275
}
7376

0 commit comments

Comments
 (0)