linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][V2] dvb_frontend: ensure that inital front end status initialized
@ 2017-07-20 22:12 Colin King
  2017-07-20 23:28 ` Shuah Khan
  2017-07-20 23:35 ` Mauro Carvalho Chehab
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2017-07-20 22:12 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Max Kellermann, Sakari Ailus,
	Markus Elfring, Ingo Molnar, 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 adding FE_NONE to the enum fe_status and initializing
s to this.

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 +-
 include/uapi/linux/dvb/frontend.h     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index e3fff8f64d37..18cc3bbc699c 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 = FE_NONE;
 	enum dvbfe_algo algo;
 	bool re_tune = false;
 	bool semheld = false;
diff --git a/include/uapi/linux/dvb/frontend.h b/include/uapi/linux/dvb/frontend.h
index 00a20cd21ee2..afc3972b0879 100644
--- a/include/uapi/linux/dvb/frontend.h
+++ b/include/uapi/linux/dvb/frontend.h
@@ -127,6 +127,7 @@ enum fe_sec_mini_cmd {
  *			to reset DiSEqC, tone and parameters
  */
 enum fe_status {
+	FE_NONE			= 0x00,
 	FE_HAS_SIGNAL		= 0x01,
 	FE_HAS_CARRIER		= 0x02,
 	FE_HAS_VITERBI		= 0x04,
-- 
2.11.0

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

* Re: [PATCH][V2] dvb_frontend: ensure that inital front end status initialized
  2017-07-20 22:12 [PATCH][V2] dvb_frontend: ensure that inital front end status initialized Colin King
@ 2017-07-20 23:28 ` Shuah Khan
  2017-07-20 23:35 ` Mauro Carvalho Chehab
  1 sibling, 0 replies; 3+ messages in thread
From: Shuah Khan @ 2017-07-20 23:28 UTC (permalink / raw)
  To: Colin King, Mauro Carvalho Chehab, Max Kellermann, Sakari Ailus,
	Markus Elfring, Ingo Molnar, Masahiro Yamada, linux-media
  Cc: kernel-janitors, linux-kernel, Shuah Khan, Shuah Khan

On 07/20/2017 04:12 PM, 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 adding FE_NONE to the enum fe_status and initializing
> s to this.
> 
> Detected by CoverityScan, CID#112887 ("Uninitialized scalar variable")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Reviewed-by: Shuah Khan <shuahkh@osg.samsung.com>


Looks good to me. Do you mind fixing dvb_frontend_swzigzag() as well.
It currently initializes enum fe_status s = 0; in a separate patch.

> ---
>  drivers/media/dvb-core/dvb_frontend.c | 2 +-
>  include/uapi/linux/dvb/frontend.h     | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
> index e3fff8f64d37..18cc3bbc699c 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 = FE_NONE;
>  	enum dvbfe_algo algo;
>  	bool re_tune = false;
>  	bool semheld = false;
> diff --git a/include/uapi/linux/dvb/frontend.h b/include/uapi/linux/dvb/frontend.h
> index 00a20cd21ee2..afc3972b0879 100644
> --- a/include/uapi/linux/dvb/frontend.h
> +++ b/include/uapi/linux/dvb/frontend.h
> @@ -127,6 +127,7 @@ enum fe_sec_mini_cmd {
>   *			to reset DiSEqC, tone and parameters
>   */
>  enum fe_status {
> +	FE_NONE			= 0x00,
>  	FE_HAS_SIGNAL		= 0x01,
>  	FE_HAS_CARRIER		= 0x02,
>  	FE_HAS_VITERBI		= 0x04,
> 

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

* Re: [PATCH][V2] dvb_frontend: ensure that inital front end status initialized
  2017-07-20 22:12 [PATCH][V2] dvb_frontend: ensure that inital front end status initialized Colin King
  2017-07-20 23:28 ` Shuah Khan
@ 2017-07-20 23:35 ` Mauro Carvalho Chehab
  1 sibling, 0 replies; 3+ messages in thread
From: Mauro Carvalho Chehab @ 2017-07-20 23:35 UTC (permalink / raw)
  To: Colin King
  Cc: Mauro Carvalho Chehab, Max Kellermann, Sakari Ailus,
	Markus Elfring, Ingo Molnar, Masahiro Yamada, Shuah Khan,
	linux-media, kernel-janitors, linux-kernel

Em Thu, 20 Jul 2017 23:12:07 +0100
Colin King <colin.king@canonical.com> escreveu:

> 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 adding FE_NONE to the enum fe_status and initializing
> s to this.
> 
> 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 +-
>  include/uapi/linux/dvb/frontend.h     | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
> index e3fff8f64d37..18cc3bbc699c 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 = FE_NONE;
>  	enum dvbfe_algo algo;
>  	bool re_tune = false;
>  	bool semheld = false;
> diff --git a/include/uapi/linux/dvb/frontend.h b/include/uapi/linux/dvb/frontend.h
> index 00a20cd21ee2..afc3972b0879 100644
> --- a/include/uapi/linux/dvb/frontend.h
> +++ b/include/uapi/linux/dvb/frontend.h
> @@ -127,6 +127,7 @@ enum fe_sec_mini_cmd {
>   *			to reset DiSEqC, tone and parameters
>   */
>  enum fe_status {
> +	FE_NONE			= 0x00,
>  	FE_HAS_SIGNAL		= 0x01,
>  	FE_HAS_CARRIER		= 0x02,
>  	FE_HAS_VITERBI		= 0x04,

If you're willing to touch the uAPI, please update its documentation:

$ git grep FE_HAS_SIGNAL Documentation/
Documentation/media/uapi/dvb/examples.rst:       if (*stat & FE_HAS_SIGNAL)
Documentation/media/uapi/dvb/fe-read-status.rst:          ``FE_HAS_SIGNAL``


Regards,
Mauro

Thanks,
Mauro

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-20 22:12 [PATCH][V2] dvb_frontend: ensure that inital front end status initialized Colin King
2017-07-20 23:28 ` Shuah Khan
2017-07-20 23:35 ` Mauro Carvalho Chehab

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