]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
media: Staging: media: Release the correct resource in an error handling path
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 20 Aug 2017 16:49:01 +0000 (12:49 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Wed, 29 May 2019 20:55:36 +0000 (16:55 -0400)
'res' is reassigned several times in the function and if we 'goto
error_unmap', its value is not the returned value of 'request_mem_region()'
anymore.

Introduce a new 'struct resource *' variable (i.e. res2) to keep a pointer
to the right resource, if needed in the error handling path.

Fixes: 4b4eda001704 ("Staging: media: Unmap and release region obtained by ioremap_nocache")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/staging/media/davinci_vpfe/dm365_ipipe.c

index 30e2edc0cec560e763bd69e9ebe24788f411d540..08c26f3c5282d7a7d50a96b03169af94942200eb 100644 (file)
@@ -1772,7 +1772,7 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct platform_device *pdev)
        struct media_pad *pads = &ipipe->pads[0];
        struct v4l2_subdev *sd = &ipipe->subdev;
        struct media_entity *me = &sd->entity;
-       struct resource *res, *memres;
+       struct resource *res, *res2, *memres;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 4);
        if (!res)
@@ -1786,11 +1786,11 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct platform_device *pdev)
        if (!ipipe->base_addr)
                goto error_release;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 6);
-       if (!res)
+       res2 = platform_get_resource(pdev, IORESOURCE_MEM, 6);
+       if (!res2)
                goto error_unmap;
-       ipipe->isp5_base_addr = ioremap_nocache(res->start,
-                                               resource_size(res));
+       ipipe->isp5_base_addr = ioremap_nocache(res2->start,
+                                               resource_size(res2));
        if (!ipipe->isp5_base_addr)
                goto error_unmap;