* [PATCH] [media] rcar_drif: fix potential uninitialized variable use
@ 2017-09-14 11:07 Arnd Bergmann
2017-09-15 8:20 ` Ramesh Shanmugasundaram
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2017-09-14 11:07 UTC (permalink / raw)
To: Ramesh Shanmugasundaram, Mauro Carvalho Chehab
Cc: Arnd Bergmann, Hans Verkuil, linux-media, linux-renesas-soc,
linux-kernel
Older compilers like gcc-4.6 may run into a case that returns
an uninitialized variable from rcar_drif_enable_rx() if that
function was ever called with an empty cur_ch_mask:
drivers/media/platform/rcar_drif.c:658:2: error: ‘ret’ may be used uninitialized in this function [-Werror=uninitialized]
Newer compilers don't have that problem as they optimize the
'ret' variable away and just return zero in that case.
This changes the function to return -EINVAL for this particular
failure, to make it consistent across all compiler versions.
In case gcc gets changed to report a warning for it in the
future, it's also a good idea to shut it up now.
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82203
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/media/platform/rcar_drif.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
index 522364ff0d5d..2c6afd38b78a 100644
--- a/drivers/media/platform/rcar_drif.c
+++ b/drivers/media/platform/rcar_drif.c
@@ -630,7 +630,7 @@ static int rcar_drif_enable_rx(struct rcar_drif_sdr *sdr)
{
unsigned int i;
u32 ctr;
- int ret;
+ int ret = -EINVAL;
/*
* When both internal channels are enabled, they can be synchronized
--
2.9.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [PATCH] [media] rcar_drif: fix potential uninitialized variable use
2017-09-14 11:07 [PATCH] [media] rcar_drif: fix potential uninitialized variable use Arnd Bergmann
@ 2017-09-15 8:20 ` Ramesh Shanmugasundaram
0 siblings, 0 replies; 2+ messages in thread
From: Ramesh Shanmugasundaram @ 2017-09-15 8:20 UTC (permalink / raw)
To: Arnd Bergmann, Mauro Carvalho Chehab
Cc: Hans Verkuil, linux-media, linux-renesas-soc, linux-kernel,
Chris Paterson
Hi Arnd,
Thank you for the patch.
> Subject: [PATCH] [media] rcar_drif: fix potential uninitialized variable
> use
>
> Older compilers like gcc-4.6 may run into a case that returns an
> uninitialized variable from rcar_drif_enable_rx() if that function was
> ever called with an empty cur_ch_mask:
>
> drivers/media/platform/rcar_drif.c:658:2: error: ‘ret’ may be used
> uninitialized in this function [-Werror=uninitialized]
>
> Newer compilers don't have that problem as they optimize the 'ret'
> variable away and just return zero in that case.
>
> This changes the function to return -EINVAL for this particular failure,
> to make it consistent across all compiler versions.
> In case gcc gets changed to report a warning for it in the future, it's
> also a good idea to shut it up now.
>
> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82203
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Ramesh Shanmugasundaram <ramesh.shanmugasundaram@bp.renesas.com>
Thanks,
Ramesh
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-15 8:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-14 11:07 [PATCH] [media] rcar_drif: fix potential uninitialized variable use Arnd Bergmann
2017-09-15 8:20 ` Ramesh Shanmugasundaram
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).