Skip to contentSkip to conversation

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

PATCH New Colin King 1 participant 1 message Jul 9, 2021

Subsystems (5)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 media: venus: venc: Fix potential null pointer dereference on pointer fmt

From: Colin Ian King <[email protected]>

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")
---
 drivers/media/platform/qcom/venus/venc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/platform/qcom/venus/venc.c +2 -0
index 8dd49d4f124c..1d62e38065d6 100644
@@ -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),
Signature · 1 line
2.31.1