diff mbox

staging: media/omap1: assign resource before use

Message ID 1460790246-3800892-1-git-send-email-arnd@arndb.de
State New
Headers show

Commit Message

Arnd Bergmann April 16, 2016, 7:03 a.m. UTC
A recent cleanup patch accidentally moved the initial assignment
of the register resource after its first use, as shown by this
gcc warning:

drivers/staging/media/omap1/omap1_camera.c: In function 'omap1_cam_probe':
include/linux/ioport.h:191:12: error: 'res' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  return res->end - res->start + 1;
         ~~~^~~~~
drivers/staging/media/omap1/omap1_camera.c:1566:19: note: 'res' was declared here
  struct resource *res;
                   ^~~

This moves the line to immediately before the location that the variable
is used in.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Fixes: 76e543382bd4 ("staging: media: omap1: Switch to devm_ioremap_resource")
---
 drivers/staging/media/omap1/omap1_camera.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.7.0
diff mbox

Patch

diff --git a/drivers/staging/media/omap1/omap1_camera.c b/drivers/staging/media/omap1/omap1_camera.c
index 54b8dd2d2bba..078049481e8b 100644
--- a/drivers/staging/media/omap1/omap1_camera.c
+++ b/drivers/staging/media/omap1/omap1_camera.c
@@ -1579,6 +1579,7 @@  static int omap1_cam_probe(struct platform_device *pdev)
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	pcdev = devm_kzalloc(&pdev->dev, sizeof(*pcdev) + resource_size(res),
 			     GFP_KERNEL);
 	if (!pcdev)
@@ -1614,7 +1615,6 @@  static int omap1_cam_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&pcdev->capture);
 	spin_lock_init(&pcdev->lock);
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(base))
 		return PTR_ERR(base);