From: Kangjie Lu Date: Sat, 9 Mar 2019 07:20:56 +0000 (-0500) Subject: media: video-mux: fix null pointer dereferences X-Git-Tag: v5.2-rc1~127^2~94 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aeb0d0f581e2079868e64a2e5ee346d340376eae;p=thirdparty%2Fkernel%2Flinux.git media: video-mux: fix null pointer dereferences devm_kcalloc may fail and return a null pointer. The fix returns -ENOMEM upon failures to avoid null pointer dereferences. Signed-off-by: Kangjie Lu Reviewed-by: Philipp Zabel Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c index 0ba30756e1e40..d8cd5f5cb10d6 100644 --- a/drivers/media/platform/video-mux.c +++ b/drivers/media/platform/video-mux.c @@ -419,9 +419,14 @@ static int video_mux_probe(struct platform_device *pdev) vmux->active = -1; vmux->pads = devm_kcalloc(dev, num_pads, sizeof(*vmux->pads), GFP_KERNEL); + if (!vmux->pads) + return -ENOMEM; + vmux->format_mbus = devm_kcalloc(dev, num_pads, sizeof(*vmux->format_mbus), GFP_KERNEL); + if (!vmux->format_mbus) + return -ENOMEM; for (i = 0; i < num_pads; i++) { vmux->pads[i].flags = (i < num_pads - 1) ? MEDIA_PAD_FL_SINK