Skip to contentSkip to conversation

davinci: vpif_capture: add NULL check on devm_kzalloc return value

PATCH New Gustavo A. R. Silva 1 participant 1 message Nov 23, 2017 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 davinci: vpif_capture: add NULL check on devm_kzalloc return value

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")
---
 drivers/media/platform/davinci/vpif_capture.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/platform/davinci/vpif_capture.c +2 -0
index a89367a..3879c7c 100644
@@ -1550,6 +1550,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;
Signature · 1 line
2.7.4