Skip to content

Commit 2a34496

Browse files
qasim-ijazAbhinav Kumar
authored andcommitted
drm/msm/dpu: reorder pointer operations after sanity checks to avoid NULL deref
_dpu_encoder_trigger_start dereferences "struct dpu_encoder_phys *phys" before the sanity checks which can lead to a NULL pointer dereference if phys is NULL. Fix this by reordering the dereference after the sanity checks. Fixes: 8144d17 ("drm/msm/dpu: Skip trigger flush and start for CWB") Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Signed-off-by: Qasim Ijaz <qasdev00@gmail.com> Reviewed-by: Jessica Zhang <quic_jesszhan@quicinc.com> Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com> Patchwork: https://patchwork.freedesktop.org/patch/647536/ Link: https://lore.kernel.org/r/20250408172223.10827-1-qasdev00@gmail.com Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
1 parent 5cb1b13 commit 2a34496

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,7 @@ static void _dpu_encoder_trigger_flush(struct drm_encoder *drm_enc,
16661666
*/
16671667
static void _dpu_encoder_trigger_start(struct dpu_encoder_phys *phys)
16681668
{
1669-
struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(phys->parent);
1669+
struct dpu_encoder_virt *dpu_enc;
16701670

16711671
if (!phys) {
16721672
DPU_ERROR("invalid argument(s)\n");
@@ -1678,6 +1678,8 @@ static void _dpu_encoder_trigger_start(struct dpu_encoder_phys *phys)
16781678
return;
16791679
}
16801680

1681+
dpu_enc = to_dpu_encoder_virt(phys->parent);
1682+
16811683
if (phys->parent->encoder_type == DRM_MODE_ENCODER_VIRTUAL &&
16821684
dpu_enc->cwb_mask) {
16831685
DPU_DEBUG("encoder %d CWB enabled, skipping\n", DRMID(phys->parent));

0 commit comments

Comments
 (0)