Skip to content

Commit

Permalink
media: video-mux: fix null pointer dereferences
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Philipp Zabel <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
kengiter authored and mchehab committed Mar 29, 2019
1 parent 99df48e commit aeb0d0f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/media/platform/video-mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aeb0d0f

Please sign in to comment.