All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: au88x0: avoid theoretical uninitialized access
@ 2017-03-23 15:15 ` Arnd Bergmann
  0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-03-23 15:15 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai
  Cc: Arnd Bergmann, Colin Ian King, alsa-devel, linux-kernel

The latest gcc-7.0.1 snapshot points out that we if nr_ch is zero, we never
initialize some variables:

sound/pci/au88x0/au88x0_core.c: In function 'vortex_adb_allocroute':
sound/pci/au88x0/au88x0_core.c:2304:68: error: 'mix[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized]
sound/pci/au88x0/au88x0_core.c:2305:58: error: 'src[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized]

I assume this can never happen in practice, but adding a check here doesn't
hurt either and avoids the warning. The code has been unchanged since
the start of git history.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 sound/pci/au88x0/au88x0_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c
index e1af24f87566..c308a4f70550 100644
--- a/sound/pci/au88x0/au88x0_core.c
+++ b/sound/pci/au88x0/au88x0_core.c
@@ -2279,6 +2279,9 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int nr_ch, int dir,
 	} else {
 		int src[2], mix[2];
 
+		if (nr_ch < 1)
+			return -EINVAL;
+
 		/* Get SRC and MIXER hardware resources. */
 		for (i = 0; i < nr_ch; i++) {
 			if ((mix[i] =
-- 
2.9.0

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

* [PATCH] ALSA: au88x0: avoid theoretical uninitialized access
@ 2017-03-23 15:15 ` Arnd Bergmann
  0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-03-23 15:15 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai
  Cc: Colin Ian King, alsa-devel, linux-kernel, Arnd Bergmann

The latest gcc-7.0.1 snapshot points out that we if nr_ch is zero, we never
initialize some variables:

sound/pci/au88x0/au88x0_core.c: In function 'vortex_adb_allocroute':
sound/pci/au88x0/au88x0_core.c:2304:68: error: 'mix[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized]
sound/pci/au88x0/au88x0_core.c:2305:58: error: 'src[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized]

I assume this can never happen in practice, but adding a check here doesn't
hurt either and avoids the warning. The code has been unchanged since
the start of git history.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 sound/pci/au88x0/au88x0_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c
index e1af24f87566..c308a4f70550 100644
--- a/sound/pci/au88x0/au88x0_core.c
+++ b/sound/pci/au88x0/au88x0_core.c
@@ -2279,6 +2279,9 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int nr_ch, int dir,
 	} else {
 		int src[2], mix[2];
 
+		if (nr_ch < 1)
+			return -EINVAL;
+
 		/* Get SRC and MIXER hardware resources. */
 		for (i = 0; i < nr_ch; i++) {
 			if ((mix[i] =
-- 
2.9.0

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

* Re: [PATCH] ALSA: au88x0: avoid theoretical uninitialized access
  2017-03-23 15:15 ` Arnd Bergmann
@ 2017-03-24 11:02   ` Takashi Iwai
  -1 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2017-03-24 11:02 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Jaroslav Kysela, alsa-devel, Colin Ian King, linux-kernel

On Thu, 23 Mar 2017 16:15:55 +0100,
Arnd Bergmann wrote:
> 
> The latest gcc-7.0.1 snapshot points out that we if nr_ch is zero, we never
> initialize some variables:
> 
> sound/pci/au88x0/au88x0_core.c: In function 'vortex_adb_allocroute':
> sound/pci/au88x0/au88x0_core.c:2304:68: error: 'mix[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> sound/pci/au88x0/au88x0_core.c:2305:58: error: 'src[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> I assume this can never happen in practice, but adding a check here doesn't
> hurt either and avoids the warning. The code has been unchanged since
> the start of git history.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Yeah, this shouldn't happen in practice, but better to cover.
I applied the patch now.  Thanks.


Takashi

> ---
>  sound/pci/au88x0/au88x0_core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c
> index e1af24f87566..c308a4f70550 100644
> --- a/sound/pci/au88x0/au88x0_core.c
> +++ b/sound/pci/au88x0/au88x0_core.c
> @@ -2279,6 +2279,9 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int nr_ch, int dir,
>  	} else {
>  		int src[2], mix[2];
>  
> +		if (nr_ch < 1)
> +			return -EINVAL;
> +
>  		/* Get SRC and MIXER hardware resources. */
>  		for (i = 0; i < nr_ch; i++) {
>  			if ((mix[i] =
> -- 
> 2.9.0
> 

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

* Re: [PATCH] ALSA: au88x0: avoid theoretical uninitialized access
@ 2017-03-24 11:02   ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2017-03-24 11:02 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Colin Ian King, alsa-devel, linux-kernel

On Thu, 23 Mar 2017 16:15:55 +0100,
Arnd Bergmann wrote:
> 
> The latest gcc-7.0.1 snapshot points out that we if nr_ch is zero, we never
> initialize some variables:
> 
> sound/pci/au88x0/au88x0_core.c: In function 'vortex_adb_allocroute':
> sound/pci/au88x0/au88x0_core.c:2304:68: error: 'mix[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> sound/pci/au88x0/au88x0_core.c:2305:58: error: 'src[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> I assume this can never happen in practice, but adding a check here doesn't
> hurt either and avoids the warning. The code has been unchanged since
> the start of git history.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Yeah, this shouldn't happen in practice, but better to cover.
I applied the patch now.  Thanks.


Takashi

> ---
>  sound/pci/au88x0/au88x0_core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c
> index e1af24f87566..c308a4f70550 100644
> --- a/sound/pci/au88x0/au88x0_core.c
> +++ b/sound/pci/au88x0/au88x0_core.c
> @@ -2279,6 +2279,9 @@ vortex_adb_allocroute(vortex_t *vortex, int dma, int nr_ch, int dir,
>  	} else {
>  		int src[2], mix[2];
>  
> +		if (nr_ch < 1)
> +			return -EINVAL;
> +
>  		/* Get SRC and MIXER hardware resources. */
>  		for (i = 0; i < nr_ch; i++) {
>  			if ((mix[i] =
> -- 
> 2.9.0
> 

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

end of thread, other threads:[~2017-03-24 11:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-23 15:15 [PATCH] ALSA: au88x0: avoid theoretical uninitialized access Arnd Bergmann
2017-03-23 15:15 ` Arnd Bergmann
2017-03-24 11:02 ` Takashi Iwai
2017-03-24 11:02   ` Takashi Iwai

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.