linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [media] dvb_frontend: ensure that front end status is initialized
@ 2017-07-20 15:29 Colin King
  2017-07-20 15:48 ` Shuah Khan
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2017-07-20 15:29 UTC (permalink / raw)
  To: Max Kellermann, Sakari Ailus, Markus Elfring, Hans Verkuil,
	Masahiro Yamada, Shuah Khan, linux-media
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The fe_status variable s is not initialized meaning it can have any
random garbage status.  This could be problematic if fe->ops.tune is
false as s is not updated by the call to fe->ops.tune() and a
subsequent check on the change status will using a garbage value.
Fix this by initializing s to zero.

Detected by CoverityScan, CID#112887 ("Uninitialized scalar variable")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/media/dvb-core/dvb_frontend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index e3fff8f64d37..e18ea1508a59 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -631,7 +631,7 @@ static int dvb_frontend_thread(void *data)
 	struct dvb_frontend *fe = data;
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	struct dvb_frontend_private *fepriv = fe->frontend_priv;
-	enum fe_status s;
+	enum fe_status s = 0;
 	enum dvbfe_algo algo;
 	bool re_tune = false;
 	bool semheld = false;
-- 
2.11.0

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

* Re: [PATCH] [media] dvb_frontend: ensure that front end status is initialized
  2017-07-20 15:29 [PATCH] [media] dvb_frontend: ensure that front end status is initialized Colin King
@ 2017-07-20 15:48 ` Shuah Khan
  0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2017-07-20 15:48 UTC (permalink / raw)
  To: Colin King, Max Kellermann, Sakari Ailus, Markus Elfring,
	Hans Verkuil, Masahiro Yamada, linux-media
  Cc: kernel-janitors, linux-kernel, Shuah Khan, Shuah Khan

Hi Colin,

On 07/20/2017 09:29 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The fe_status variable s is not initialized meaning it can have any
> random garbage status.  This could be problematic if fe->ops.tune is
> false as s is not updated by the call to fe->ops.tune() and a
> subsequent check on the change status will using a garbage value.
> Fix this by initializing s to zero.
> 
> Detected by CoverityScan, CID#112887 ("Uninitialized scalar variable")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/media/dvb-core/dvb_frontend.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
> index e3fff8f64d37..e18ea1508a59 100644
> --- a/drivers/media/dvb-core/dvb_frontend.c
> +++ b/drivers/media/dvb-core/dvb_frontend.c
> @@ -631,7 +631,7 @@ static int dvb_frontend_thread(void *data)
>  	struct dvb_frontend *fe = data;
>  	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
>  	struct dvb_frontend_private *fepriv = fe->frontend_priv;
> -	enum fe_status s;
> +	enum fe_status s = 0;

0 isn't a valid value for enum fe_status. I think the right fix would be
to add FE_NONE to enum fe_status and then initialize s to that.

thanks,
-- Shuah


>  	enum dvbfe_algo algo;
>  	bool re_tune = false;
>  	bool semheld = false;
> 

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

end of thread, other threads:[~2017-07-20 15:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-20 15:29 [PATCH] [media] dvb_frontend: ensure that front end status is initialized Colin King
2017-07-20 15:48 ` Shuah Khan

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).