OSDN Git Service

[media] media: v4l2-pci-skeleton: Fix error handling path in 'skeleton_probe()'
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 11 Sep 2017 16:53:07 +0000 (13:53 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Wed, 4 Oct 2017 19:55:02 +0000 (16:55 -0300)
If this memory allocation fails, we must release some resources, as
already done in the code below and above.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
samples/v4l/v4l2-pci-skeleton.c

index 483e9bc..f520e3a 100644 (file)
@@ -772,8 +772,10 @@ static int skeleton_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        /* Allocate a new instance */
        skel = devm_kzalloc(&pdev->dev, sizeof(struct skeleton), GFP_KERNEL);
-       if (!skel)
-               return -ENOMEM;
+       if (!skel) {
+               ret = -ENOMEM;
+               goto disable_pci;
+       }
 
        /* Allocate the interrupt */
        ret = devm_request_irq(&pdev->dev, pdev->irq,