public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] ALSA: firewire-tascam: off by one in identify_model()
@ 2015-10-15 18:18 Dan Carpenter
  2015-10-17 10:11 ` Takashi Iwai
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2015-10-15 18:18 UTC (permalink / raw)
  To: Clemens Ladisch, Takashi Sakamoto
  Cc: Jaroslav Kysela, Takashi Iwai, alsa-devel, kernel-janitors

In the original code, we potentially put a NUL character in model[8] and
it caused a static checker warning.  We can put the NUL in model[7]
instead.

Fixes: 53b3ffee7885 ('ALSA: firewire-tascam: change device probing processing')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/sound/firewire/tascam/tascam.c b/sound/firewire/tascam/tascam.c
index c6747a4..6ef2bcc 100644
--- a/sound/firewire/tascam/tascam.c
+++ b/sound/firewire/tascam/tascam.c
@@ -51,7 +51,7 @@ static int identify_model(struct snd_tscm *tscm)
 	}
 
 	/* Pick up model name from certain addresses. */
-	for (i = 0; i < 8; i++) {
+	for (i = 0; i < 7; i++) {
 		c = config_rom[28 + i / 4] >> (24 - 8 * (i % 4));
 		if (c = '\0')
 			break;

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

* Re: [patch] ALSA: firewire-tascam: off by one in identify_model()
  2015-10-15 18:18 [patch] ALSA: firewire-tascam: off by one in identify_model() Dan Carpenter
@ 2015-10-17 10:11 ` Takashi Iwai
  2015-10-17 12:02   ` Dan Carpenter
  0 siblings, 1 reply; 7+ messages in thread
From: Takashi Iwai @ 2015-10-17 10:11 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Clemens Ladisch, Takashi Sakamoto, alsa-devel, Jaroslav Kysela,
	kernel-janitors

On Thu, 15 Oct 2015 20:18:29 +0200,
Dan Carpenter wrote:
> 
> In the original code, we potentially put a NUL character in model[8] and
> it caused a static checker warning.  We can put the NUL in model[7]
> instead.

I guess it's better to expand model[] to 9 bytes instead.  The logic
is to retrieve the string from the config rom, and it's up to 8
letters.


thanks,

Takashi

> 
> Fixes: 53b3ffee7885 ('ALSA: firewire-tascam: change device probing processing')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/sound/firewire/tascam/tascam.c b/sound/firewire/tascam/tascam.c
> index c6747a4..6ef2bcc 100644
> --- a/sound/firewire/tascam/tascam.c
> +++ b/sound/firewire/tascam/tascam.c
> @@ -51,7 +51,7 @@ static int identify_model(struct snd_tscm *tscm)
>  	}
>  
>  	/* Pick up model name from certain addresses. */
> -	for (i = 0; i < 8; i++) {
> +	for (i = 0; i < 7; i++) {
>  		c = config_rom[28 + i / 4] >> (24 - 8 * (i % 4));
>  		if (c = '\0')
>  			break;
> 

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

* Re: [patch] ALSA: firewire-tascam: off by one in identify_model()
  2015-10-17 10:11 ` Takashi Iwai
@ 2015-10-17 12:02   ` Dan Carpenter
  2015-10-18  1:00     ` Takashi Sakamoto
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2015-10-17 12:02 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Clemens Ladisch, Takashi Sakamoto, alsa-devel, Jaroslav Kysela,
	kernel-janitors

On Sat, Oct 17, 2015 at 12:11:58PM +0200, Takashi Iwai wrote:
> On Thu, 15 Oct 2015 20:18:29 +0200,
> Dan Carpenter wrote:
> > 
> > In the original code, we potentially put a NUL character in model[8] and
> > it caused a static checker warning.  We can put the NUL in model[7]
> > instead.
> 
> I guess it's better to expand model[] to 9 bytes instead.  The logic
> is to retrieve the string from the config rom, and it's up to 8
> letters.

Ok.  I will resend.

regards,
dan carpenter


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

* Re: [patch] ALSA: firewire-tascam: off by one in identify_model()
  2015-10-17 12:02   ` Dan Carpenter
@ 2015-10-18  1:00     ` Takashi Sakamoto
  2015-10-19 11:29       ` [patch v2] " Dan Carpenter
  0 siblings, 1 reply; 7+ messages in thread
From: Takashi Sakamoto @ 2015-10-18  1:00 UTC (permalink / raw)
  To: Dan Carpenter, Takashi Iwai
  Cc: Clemens Ladisch, alsa-devel, Jaroslav Kysela, kernel-janitors

On Oct 17 2015 21:02, Dan Carpenter wrote:
> On Sat, Oct 17, 2015 at 12:11:58PM +0200, Takashi Iwai wrote:
>> On Thu, 15 Oct 2015 20:18:29 +0200,
>> Dan Carpenter wrote:
>>>
>>> In the original code, we potentially put a NUL character in model[8] and
>>> it caused a static checker warning.  We can put the NUL in model[7]
>>> instead.
>>
>> I guess it's better to expand model[] to 9 bytes instead.  The logic
>> is to retrieve the string from the config rom, and it's up to 8
>> letters.
> 
> Ok.  I will resend.

I think this idea is better, too.


Thanks

Takashi Sakamoto

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

* [patch v2] ALSA: firewire-tascam: off by one in identify_model()
  2015-10-18  1:00     ` Takashi Sakamoto
@ 2015-10-19 11:29       ` Dan Carpenter
  2015-10-19 11:54         ` Takashi Sakamoto
  2015-10-19 12:01         ` Takashi Iwai
  0 siblings, 2 replies; 7+ messages in thread
From: Dan Carpenter @ 2015-10-19 11:29 UTC (permalink / raw)
  To: Clemens Ladisch
  Cc: Jaroslav Kysela, Takashi Iwai, Takashi Sakamoto, alsa-devel,
	kernel-janitors

Let's leave space for the NUL char otherwise the static checkers
complain that we go beyond the end of the array.

Fixes: 53b3ffee7885 ('ALSA: firewire-tascam: change device probing processing') 
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: I truncated the last char in v1 instead of making the buffer larger

diff --git a/sound/firewire/tascam/tascam.c b/sound/firewire/tascam/tascam.c
index c6747a4..79cb9e9 100644
--- a/sound/firewire/tascam/tascam.c
+++ b/sound/firewire/tascam/tascam.c
@@ -40,7 +40,7 @@ static int identify_model(struct snd_tscm *tscm)
 {
 	struct fw_device *fw_dev = fw_parent_device(tscm->unit);
 	const u32 *config_rom = fw_dev->config_rom;
-	char model[8];
+	char model[9];
 	unsigned int i;
 	u8 c;
 

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

* Re: [patch v2] ALSA: firewire-tascam: off by one in identify_model()
  2015-10-19 11:29       ` [patch v2] " Dan Carpenter
@ 2015-10-19 11:54         ` Takashi Sakamoto
  2015-10-19 12:01         ` Takashi Iwai
  1 sibling, 0 replies; 7+ messages in thread
From: Takashi Sakamoto @ 2015-10-19 11:54 UTC (permalink / raw)
  To: Dan Carpenter, Clemens Ladisch
  Cc: Jaroslav Kysela, Takashi Iwai, alsa-devel, kernel-janitors

On Oct 19 2015 20:29, Dan Carpenter wrote:
> Let's leave space for the NUL char otherwise the static checkers
> complain that we go beyond the end of the array.
> 
> Fixes: 53b3ffee7885 ('ALSA: firewire-tascam: change device probing processing') 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>


Thank you to fix it.

Takashi Sakamoto

> ---
> v2: I truncated the last char in v1 instead of making the buffer larger
> 
> diff --git a/sound/firewire/tascam/tascam.c b/sound/firewire/tascam/tascam.c
> index c6747a4..79cb9e9 100644
> --- a/sound/firewire/tascam/tascam.c
> +++ b/sound/firewire/tascam/tascam.c
> @@ -40,7 +40,7 @@ static int identify_model(struct snd_tscm *tscm)
>  {
>  	struct fw_device *fw_dev = fw_parent_device(tscm->unit);
>  	const u32 *config_rom = fw_dev->config_rom;
> -	char model[8];
> +	char model[9];
>  	unsigned int i;
>  	u8 c;
>  
> 


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

* Re: [patch v2] ALSA: firewire-tascam: off by one in identify_model()
  2015-10-19 11:29       ` [patch v2] " Dan Carpenter
  2015-10-19 11:54         ` Takashi Sakamoto
@ 2015-10-19 12:01         ` Takashi Iwai
  1 sibling, 0 replies; 7+ messages in thread
From: Takashi Iwai @ 2015-10-19 12:01 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Clemens Ladisch, alsa-devel, Jaroslav Kysela, Takashi Sakamoto,
	kernel-janitors

On Mon, 19 Oct 2015 13:29:27 +0200,
Dan Carpenter wrote:
> 
> Let's leave space for the NUL char otherwise the static checkers
> complain that we go beyond the end of the array.
> 
> Fixes: 53b3ffee7885 ('ALSA: firewire-tascam: change device probing processing') 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: I truncated the last char in v1 instead of making the buffer larger

Applied, thanks.


Takashi

> 
> diff --git a/sound/firewire/tascam/tascam.c b/sound/firewire/tascam/tascam.c
> index c6747a4..79cb9e9 100644
> --- a/sound/firewire/tascam/tascam.c
> +++ b/sound/firewire/tascam/tascam.c
> @@ -40,7 +40,7 @@ static int identify_model(struct snd_tscm *tscm)
>  {
>  	struct fw_device *fw_dev = fw_parent_device(tscm->unit);
>  	const u32 *config_rom = fw_dev->config_rom;
> -	char model[8];
> +	char model[9];
>  	unsigned int i;
>  	u8 c;
>  
> 

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

end of thread, other threads:[~2015-10-19 12:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-15 18:18 [patch] ALSA: firewire-tascam: off by one in identify_model() Dan Carpenter
2015-10-17 10:11 ` Takashi Iwai
2015-10-17 12:02   ` Dan Carpenter
2015-10-18  1:00     ` Takashi Sakamoto
2015-10-19 11:29       ` [patch v2] " Dan Carpenter
2015-10-19 11:54         ` Takashi Sakamoto
2015-10-19 12:01         ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox