Skip to content

Commit 106a6de

Browse files
diandersChun-Kuang Hu
authored andcommitted
drm/mediatek: dp: drm_err => dev_err in HPD path to avoid NULL ptr
The function mtk_dp_wait_hpd_asserted() may be called before the `mtk_dp->drm_dev` pointer is assigned in mtk_dp_bridge_attach(). Specifically it can be called via this callpath: - mtk_edp_wait_hpd_asserted - [panel probe] - dp_aux_ep_probe Using "drm" level prints anywhere in this callpath causes a NULL pointer dereference. Change the error message directly in mtk_dp_wait_hpd_asserted() to dev_err() to avoid this. Also change the error messages in mtk_dp_parse_capabilities(), which is called by mtk_dp_wait_hpd_asserted(). While touching these prints, also add the error code to them to make future debugging easier. Fixes: 7eacba9 ("drm/mediatek: dp: Add .wait_hpd_asserted() for AUX bus") Signed-off-by: Douglas Anderson <[email protected]> Reviewed-by: CK Hu <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/20250116094249.1.I29b0b621abb613ddc70ab4996426a3909e1aa75f@changeid/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent 4ba973c commit 106a6de

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/gpu/drm/mediatek/mtk_dp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,7 @@ static int mtk_dp_parse_capabilities(struct mtk_dp *mtk_dp)
17661766

17671767
ret = drm_dp_dpcd_readb(&mtk_dp->aux, DP_MSTM_CAP, &val);
17681768
if (ret < 1) {
1769-
drm_err(mtk_dp->drm_dev, "Read mstm cap failed\n");
1769+
dev_err(mtk_dp->dev, "Read mstm cap failed: %zd\n", ret);
17701770
return ret == 0 ? -EIO : ret;
17711771
}
17721772

@@ -1776,7 +1776,7 @@ static int mtk_dp_parse_capabilities(struct mtk_dp *mtk_dp)
17761776
DP_DEVICE_SERVICE_IRQ_VECTOR_ESI0,
17771777
&val);
17781778
if (ret < 1) {
1779-
drm_err(mtk_dp->drm_dev, "Read irq vector failed\n");
1779+
dev_err(mtk_dp->dev, "Read irq vector failed: %zd\n", ret);
17801780
return ret == 0 ? -EIO : ret;
17811781
}
17821782

@@ -2059,7 +2059,7 @@ static int mtk_dp_wait_hpd_asserted(struct drm_dp_aux *mtk_aux, unsigned long wa
20592059

20602060
ret = mtk_dp_parse_capabilities(mtk_dp);
20612061
if (ret) {
2062-
drm_err(mtk_dp->drm_dev, "Can't parse capabilities\n");
2062+
dev_err(mtk_dp->dev, "Can't parse capabilities: %d\n", ret);
20632063
return ret;
20642064
}
20652065

0 commit comments

Comments
 (0)