media: davinci: vpif_capture: add NULL check on devm_kzalloc return value
authorGustavo A. R. Silva <garsilva@embeddedor.com>
Thu, 23 Nov 2017 03:34:44 +0000 (22:34 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Mar 2018 07:42:54 +0000 (08:42 +0100)
[ Upstream commit 5a18c2434f8bfc8bc2fb0f8af3e44f7408d63e4f ]

Check return value from call to devm_kzalloc() in order to prevent
a NULL pointer dereference.

This issue was detected with the help of Coccinelle.

Fixes: 4a5f8ae50b66 ("[media] davinci: vpif_capture: get subdevs from DT when available")

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/platform/davinci/vpif_capture.c

index 0ef36cec21d11f847b531c037c976d8382d0cfc3..233622bef4a53a85495c3add269a7c27d533966e 100644 (file)
@@ -1545,6 +1545,8 @@ vpif_capture_get_pdata(struct platform_device *pdev)
                                            sizeof(*chan->inputs) *
                                            VPIF_CAPTURE_NUM_CHANNELS,
                                            GFP_KERNEL);
+               if (!chan->inputs)
+                       return NULL;
 
                chan->input_count++;
                chan->inputs[i].input.type = V4L2_INPUT_TYPE_CAMERA;