]> git.itanic.dy.fi Git - linux-stable/commitdiff
media: venus: venc: Fix potential null pointer dereference on pointer fmt
authorColin Ian King <colin.king@canonical.com>
Fri, 9 Jul 2021 12:30:25 +0000 (14:30 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 4 Aug 2021 12:43:52 +0000 (14:43 +0200)
Currently the call to find_format can potentially return a NULL to
fmt and the nullpointer is later dereferenced on the assignment of
pixmp->num_planes = fmt->num_planes.  Fix this by adding a NULL pointer
check and returning NULL for the failure case.

Addresses-Coverity: ("Dereference null return")

Fixes: aaaa93eda64b ("[media] media: venus: venc: add video encoder files")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/qcom/venus/venc.c

index 8dd49d4f124cb561597c31b209fa219fc7678e7c..1d62e38065d62320da18cd4a3336e1ee479c123b 100644 (file)
@@ -183,6 +183,8 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
                else
                        return NULL;
                fmt = find_format(inst, pixmp->pixelformat, f->type);
+               if (!fmt)
+                       return NULL;
        }
 
        pixmp->width = clamp(pixmp->width, frame_width_min(inst),