]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
media: video-mux: fix null pointer dereferences
authorKangjie Lu <kjlu@umn.edu>
Sat, 9 Mar 2019 07:20:56 +0000 (02:20 -0500)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1838700
[ Upstream commit aeb0d0f581e2079868e64a2e5ee346d340376eae ]

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 <kjlu@umn.edu>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/media/platform/video-mux.c

index ee89ad76bee2341ed5d5f87746dc3135839e6d2e..eedc0b99a891e2d612bbd6798a23e7b86334dbba 100644 (file)
@@ -242,9 +242,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 - 1; i++)
                vmux->pads[i].flags = MEDIA_PAD_FL_SINK;