All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [media] DaVinci-VPFE-Capture: fix error handling
@ 2016-11-22 20:52 Arnd Bergmann
  2016-11-23 18:24 ` SF Markus Elfring
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2016-11-22 20:52 UTC (permalink / raw)
  To: Lad, Prabhakar, Mauro Carvalho Chehab
  Cc: Arnd Bergmann, Hans Verkuil, Markus Elfring, linux-media, linux-kernel

A recent cleanup had the right idea to remove the initialization
of the error variable, but missed the actual benefit of that,
which is that we get warnings if there is a bug in it. Now
we get a warning about a bug that was introduced by this cleanup:

drivers/media/platform/davinci/vpfe_capture.c: In function 'vpfe_probe':
drivers/media/platform/davinci/vpfe_capture.c:1992:9: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This adds the missing initialization that the warning is about,
and another one that was preexisting and that we did not get
a warning for. That second bug has existed since the driver
was first added.

Fixes: efb74461f5a6 ("[media] DaVinci-VPFE-Capture: Delete an unnecessary variable initialisation in vpfe_probe()")
Fixes: 7da8a6cb3e5b ("V4L/DVB (12248): v4l: vpfe capture bridge driver for DM355 and DM6446")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/media/platform/davinci/vpfe_capture.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c
index 6c41782b3ba0..ee1cd79739c8 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -1847,8 +1847,10 @@ static int vpfe_probe(struct platform_device *pdev)
 
 	/* Allocate memory for ccdc configuration */
 	ccdc_cfg = kmalloc(sizeof(*ccdc_cfg), GFP_KERNEL);
-	if (!ccdc_cfg)
+	if (!ccdc_cfg) {
+		ret = -ENOMEM;
 		goto probe_free_dev_mem;
+	}
 
 	mutex_lock(&ccdc_lock);
 
@@ -1964,6 +1966,7 @@ static int vpfe_probe(struct platform_device *pdev)
 			v4l2_info(&vpfe_dev->v4l2_dev,
 				  "v4l2 sub device %s register fails\n",
 				  sdinfo->name);
+			ret = -ENXIO;
 			goto probe_sd_out;
 		}
 	}
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] [media] DaVinci-VPFE-Capture: fix error handling
  2016-11-22 20:52 [PATCH] [media] DaVinci-VPFE-Capture: fix error handling Arnd Bergmann
@ 2016-11-23 18:24 ` SF Markus Elfring
  0 siblings, 0 replies; 2+ messages in thread
From: SF Markus Elfring @ 2016-11-23 18:24 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Lad, Prabhakar, Mauro Carvalho Chehab, Hans Verkuil, linux-media,
	linux-kernel

> A recent cleanup had the right idea to remove the initialization
> of the error variable, but missed the actual benefit of that,
> which is that we get warnings if there is a bug in it.
> Now we get a warning about a bug that was introduced by this cleanup:
> 
> drivers/media/platform/davinci/vpfe_capture.c: In function 'vpfe_probe':
> drivers/media/platform/davinci/vpfe_capture.c:1992:9: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Thanks for your information.


> This adds the missing initialization that the warning is about,

I have got the impression that an other wording would be more appropriate.


> and another one that was preexisting and that we did not get
> a warning for. That second bug has existed since the driver
> was first added.

Do you distinguish better between the setting for two return values because of either
a memory allocation failure and a failed call of the function "v4l2_i2c_new_subdev_board" here?


> Fixes: efb74461f5a6 ("[media] DaVinci-VPFE-Capture: Delete an unnecessary variable initialisation in vpfe_probe()")
> Fixes: 7da8a6cb3e5b ("V4L/DVB (12248): v4l: vpfe capture bridge driver for DM355 and DM6446")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/media/platform/davinci/vpfe_capture.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c
> index 6c41782b3ba0..ee1cd79739c8 100644
> --- a/drivers/media/platform/davinci/vpfe_capture.c
> +++ b/drivers/media/platform/davinci/vpfe_capture.c
> @@ -1847,8 +1847,10 @@ static int vpfe_probe(struct platform_device *pdev)
>  
>  	/* Allocate memory for ccdc configuration */
>  	ccdc_cfg = kmalloc(sizeof(*ccdc_cfg), GFP_KERNEL);
> -	if (!ccdc_cfg)
> +	if (!ccdc_cfg) {
> +		ret = -ENOMEM;
>  		goto probe_free_dev_mem;
> +	}
>  
>  	mutex_lock(&ccdc_lock);
>  
> @@ -1964,6 +1966,7 @@ static int vpfe_probe(struct platform_device *pdev)
>  			v4l2_info(&vpfe_dev->v4l2_dev,
>  				  "v4l2 sub device %s register fails\n",
>  				  sdinfo->name);
> +			ret = -ENXIO;
>  			goto probe_sd_out;
>  		}
>  	}
> 

Thanks for your source code correction.

Regards,
Markus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-23 18:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-22 20:52 [PATCH] [media] DaVinci-VPFE-Capture: fix error handling Arnd Bergmann
2016-11-23 18:24 ` SF Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.