[PATCH] staging: media/omap1: assign resource before use

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
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(-)

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);
-- 
2.7.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux