Skip to content

Commit 170b222

Browse files
JoseExpositolumag
authored andcommitted
drm/msm/dpu: invalid parameter check in dpu_setup_dspp_pcc
The function performs a check on the "ctx" input parameter, however, it is used before the check. Initialize the "base" variable after the sanity check to avoid a possible NULL pointer dereference. Fixes: 4259ff7 ("drm/msm/dpu: add support for pcc color block in dpu driver") Addresses-Coverity-ID: 1493866 ("Null pointer dereference") Signed-off-by: José Expósito <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent 774fe0c commit 170b222

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,16 @@ static void dpu_setup_dspp_pcc(struct dpu_hw_dspp *ctx,
2626
struct dpu_hw_pcc_cfg *cfg)
2727
{
2828

29-
u32 base = ctx->cap->sblk->pcc.base;
29+
u32 base;
3030

31-
if (!ctx || !base) {
31+
if (!ctx) {
32+
DRM_ERROR("invalid ctx %pK\n", ctx);
33+
return;
34+
}
35+
36+
base = ctx->cap->sblk->pcc.base;
37+
38+
if (!base) {
3239
DRM_ERROR("invalid ctx %pK pcc base 0x%x\n", ctx, base);
3340
return;
3441
}

0 commit comments

Comments
 (0)