Commit 8bf71a57 authored by Jessica Zhang's avatar Jessica Zhang Committed by Rob Clark

drm/msm: Fix potential NULL dereference in DPU SSPP

Move initialization of sblk in _sspp_subblk_offset() after NULL check to
avoid potential NULL pointer dereference.

Fixes: 25fdd593 ("drm/msm: Add SDM845 DPU support")
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarJessica Zhang <jesszhan@codeaurora.org>
Link: https://lore.kernel.org/r/20211020175733.3379-1-jesszhan@codeaurora.orgSigned-off-by: default avatarRob Clark <robdclark@chromium.org>
parent 57fd4f34
...@@ -138,11 +138,13 @@ static int _sspp_subblk_offset(struct dpu_hw_pipe *ctx, ...@@ -138,11 +138,13 @@ static int _sspp_subblk_offset(struct dpu_hw_pipe *ctx,
u32 *idx) u32 *idx)
{ {
int rc = 0; int rc = 0;
const struct dpu_sspp_sub_blks *sblk = ctx->cap->sblk; const struct dpu_sspp_sub_blks *sblk;
if (!ctx) if (!ctx || !ctx->cap || !ctx->cap->sblk)
return -EINVAL; return -EINVAL;
sblk = ctx->cap->sblk;
switch (s_id) { switch (s_id) {
case DPU_SSPP_SRC: case DPU_SSPP_SRC:
*idx = sblk->src_blk.base; *idx = sblk->src_blk.base;
...@@ -419,7 +421,7 @@ static void _dpu_hw_sspp_setup_scaler3(struct dpu_hw_pipe *ctx, ...@@ -419,7 +421,7 @@ static void _dpu_hw_sspp_setup_scaler3(struct dpu_hw_pipe *ctx,
(void)pe; (void)pe;
if (_sspp_subblk_offset(ctx, DPU_SSPP_SCALER_QSEED3, &idx) || !sspp if (_sspp_subblk_offset(ctx, DPU_SSPP_SCALER_QSEED3, &idx) || !sspp
|| !scaler3_cfg || !ctx || !ctx->cap || !ctx->cap->sblk) || !scaler3_cfg)
return; return;
dpu_hw_setup_scaler3(&ctx->hw, scaler3_cfg, idx, dpu_hw_setup_scaler3(&ctx->hw, scaler3_cfg, idx,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment