Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: venus: venc: Fix potential null pointer dereference on pointer fmt

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>

authored by

Colin Ian King and committed by
Mauro Carvalho Chehab
09ea9719 331e06bb

+2
+2
drivers/media/platform/qcom/venus/venc.c
··· 183 183 else 184 184 return NULL; 185 185 fmt = find_format(inst, pixmp->pixelformat, f->type); 186 + if (!fmt) 187 + return NULL; 186 188 } 187 189 188 190 pixmp->width = clamp(pixmp->width, frame_width_min(inst),