* [PATCH] ALSA: pci: lx6464es: fix a debug loop
@ 2023-01-26 9:30 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2023-01-26 9:30 UTC (permalink / raw)
To: Jaroslav Kysela, Maxime Ripard; +Cc: Takashi Iwai, alsa-devel, kernel-janitors
This loop accidentally reuses the "i" iterator for both the inside and
the outside loop. The value of MAX_STREAM_BUFFER is 5. I believe that
chip->rmh.stat_len is in the 2-12 range. If the value of .stat_len is
4 or more then it will loop exactly one time, but if it's less then it
is a forever loop.
Fixes: 8e6320064c33 ("ALSA: lx_core: Remove useless #if 0 .. #endif")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
sound/pci/lx6464es/lx_core.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c
index d3f58a3d17fb..7c1b380a54c0 100644
--- a/sound/pci/lx6464es/lx_core.c
+++ b/sound/pci/lx6464es/lx_core.c
@@ -493,13 +493,11 @@ int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture,
dev_dbg(chip->card->dev,
"CMD_08_ASK_BUFFERS: needed %d, freed %d\n",
*r_needed, *r_freed);
- for (i = 0; i < MAX_STREAM_BUFFER; ++i) {
- for (i = 0; i != chip->rmh.stat_len; ++i)
- dev_dbg(chip->card->dev,
- " stat[%d]: %x, %x\n", i,
- chip->rmh.stat[i],
- chip->rmh.stat[i] & MASK_DATA_SIZE);
- }
+ for (i = 0; i < chip->rmh.stat_len; ++i)
+ dev_dbg(chip->card->dev,
+ " stat[%d]: %x, %x\n", i,
+ chip->rmh.stat[i],
+ chip->rmh.stat[i] & MASK_DATA_SIZE);
}
mutex_unlock(&chip->msg_lock);
--
2.35.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] ALSA: pci: lx6464es: fix a debug loop
@ 2023-01-26 9:30 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2023-01-26 9:30 UTC (permalink / raw)
To: Jaroslav Kysela, Maxime Ripard; +Cc: alsa-devel, kernel-janitors, Takashi Iwai
This loop accidentally reuses the "i" iterator for both the inside and
the outside loop. The value of MAX_STREAM_BUFFER is 5. I believe that
chip->rmh.stat_len is in the 2-12 range. If the value of .stat_len is
4 or more then it will loop exactly one time, but if it's less then it
is a forever loop.
Fixes: 8e6320064c33 ("ALSA: lx_core: Remove useless #if 0 .. #endif")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
sound/pci/lx6464es/lx_core.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c
index d3f58a3d17fb..7c1b380a54c0 100644
--- a/sound/pci/lx6464es/lx_core.c
+++ b/sound/pci/lx6464es/lx_core.c
@@ -493,13 +493,11 @@ int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture,
dev_dbg(chip->card->dev,
"CMD_08_ASK_BUFFERS: needed %d, freed %d\n",
*r_needed, *r_freed);
- for (i = 0; i < MAX_STREAM_BUFFER; ++i) {
- for (i = 0; i != chip->rmh.stat_len; ++i)
- dev_dbg(chip->card->dev,
- " stat[%d]: %x, %x\n", i,
- chip->rmh.stat[i],
- chip->rmh.stat[i] & MASK_DATA_SIZE);
- }
+ for (i = 0; i < chip->rmh.stat_len; ++i)
+ dev_dbg(chip->card->dev,
+ " stat[%d]: %x, %x\n", i,
+ chip->rmh.stat[i],
+ chip->rmh.stat[i] & MASK_DATA_SIZE);
}
mutex_unlock(&chip->msg_lock);
--
2.35.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ALSA: pci: lx6464es: fix a debug loop
2023-01-26 9:30 ` Dan Carpenter
@ 2023-01-26 12:53 ` Takashi Iwai
-1 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2023-01-26 12:53 UTC (permalink / raw)
To: Dan Carpenter
Cc: Jaroslav Kysela, Maxime Ripard, Takashi Iwai, alsa-devel,
kernel-janitors
On Thu, 26 Jan 2023 10:30:02 +0100,
Dan Carpenter wrote:
>
> This loop accidentally reuses the "i" iterator for both the inside and
> the outside loop. The value of MAX_STREAM_BUFFER is 5. I believe that
> chip->rmh.stat_len is in the 2-12 range. If the value of .stat_len is
> 4 or more then it will loop exactly one time, but if it's less then it
> is a forever loop.
>
> Fixes: 8e6320064c33 ("ALSA: lx_core: Remove useless #if 0 .. #endif")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> sound/pci/lx6464es/lx_core.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c
> index d3f58a3d17fb..7c1b380a54c0 100644
> --- a/sound/pci/lx6464es/lx_core.c
> +++ b/sound/pci/lx6464es/lx_core.c
> @@ -493,13 +493,11 @@ int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture,
> dev_dbg(chip->card->dev,
> "CMD_08_ASK_BUFFERS: needed %d, freed %d\n",
> *r_needed, *r_freed);
> - for (i = 0; i < MAX_STREAM_BUFFER; ++i) {
> - for (i = 0; i != chip->rmh.stat_len; ++i)
> - dev_dbg(chip->card->dev,
> - " stat[%d]: %x, %x\n", i,
> - chip->rmh.stat[i],
> - chip->rmh.stat[i] & MASK_DATA_SIZE);
> - }
> + for (i = 0; i < chip->rmh.stat_len; ++i)
Judging from the previous lines, the access over MAX_STREAM_BUFFER
might be unsafe. So I guess a more safer change would be something
like:
for (i = 0; i < MAX_STREAM_BUFFER && chip->rmh.stat_len; ++i)
Care to resubmit with it?
Thanks!
Takashi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ALSA: pci: lx6464es: fix a debug loop
@ 2023-01-26 12:53 ` Takashi Iwai
0 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2023-01-26 12:53 UTC (permalink / raw)
To: Dan Carpenter; +Cc: alsa-devel, kernel-janitors, Takashi Iwai, Maxime Ripard
On Thu, 26 Jan 2023 10:30:02 +0100,
Dan Carpenter wrote:
>
> This loop accidentally reuses the "i" iterator for both the inside and
> the outside loop. The value of MAX_STREAM_BUFFER is 5. I believe that
> chip->rmh.stat_len is in the 2-12 range. If the value of .stat_len is
> 4 or more then it will loop exactly one time, but if it's less then it
> is a forever loop.
>
> Fixes: 8e6320064c33 ("ALSA: lx_core: Remove useless #if 0 .. #endif")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> sound/pci/lx6464es/lx_core.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c
> index d3f58a3d17fb..7c1b380a54c0 100644
> --- a/sound/pci/lx6464es/lx_core.c
> +++ b/sound/pci/lx6464es/lx_core.c
> @@ -493,13 +493,11 @@ int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture,
> dev_dbg(chip->card->dev,
> "CMD_08_ASK_BUFFERS: needed %d, freed %d\n",
> *r_needed, *r_freed);
> - for (i = 0; i < MAX_STREAM_BUFFER; ++i) {
> - for (i = 0; i != chip->rmh.stat_len; ++i)
> - dev_dbg(chip->card->dev,
> - " stat[%d]: %x, %x\n", i,
> - chip->rmh.stat[i],
> - chip->rmh.stat[i] & MASK_DATA_SIZE);
> - }
> + for (i = 0; i < chip->rmh.stat_len; ++i)
Judging from the previous lines, the access over MAX_STREAM_BUFFER
might be unsafe. So I guess a more safer change would be something
like:
for (i = 0; i < MAX_STREAM_BUFFER && chip->rmh.stat_len; ++i)
Care to resubmit with it?
Thanks!
Takashi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ALSA: pci: lx6464es: fix a debug loop
2023-01-26 12:53 ` Takashi Iwai
@ 2023-01-26 16:39 ` Dan Carpenter
-1 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2023-01-26 16:39 UTC (permalink / raw)
To: Takashi Iwai
Cc: Jaroslav Kysela, Maxime Ripard, Takashi Iwai, alsa-devel,
kernel-janitors
On Thu, Jan 26, 2023 at 01:53:01PM +0100, Takashi Iwai wrote:
> On Thu, 26 Jan 2023 10:30:02 +0100,
> Dan Carpenter wrote:
> >
> > This loop accidentally reuses the "i" iterator for both the inside and
> > the outside loop. The value of MAX_STREAM_BUFFER is 5. I believe that
> > chip->rmh.stat_len is in the 2-12 range. If the value of .stat_len is
> > 4 or more then it will loop exactly one time, but if it's less then it
> > is a forever loop.
> >
> > Fixes: 8e6320064c33 ("ALSA: lx_core: Remove useless #if 0 .. #endif")
> > Signed-off-by: Dan Carpenter <error27@gmail.com>
> > ---
> > sound/pci/lx6464es/lx_core.c | 12 +++++-------
> > 1 file changed, 5 insertions(+), 7 deletions(-)
> >
> > diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c
> > index d3f58a3d17fb..7c1b380a54c0 100644
> > --- a/sound/pci/lx6464es/lx_core.c
> > +++ b/sound/pci/lx6464es/lx_core.c
> > @@ -493,13 +493,11 @@ int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture,
> > dev_dbg(chip->card->dev,
> > "CMD_08_ASK_BUFFERS: needed %d, freed %d\n",
> > *r_needed, *r_freed);
> > - for (i = 0; i < MAX_STREAM_BUFFER; ++i) {
> > - for (i = 0; i != chip->rmh.stat_len; ++i)
> > - dev_dbg(chip->card->dev,
> > - " stat[%d]: %x, %x\n", i,
> > - chip->rmh.stat[i],
> > - chip->rmh.stat[i] & MASK_DATA_SIZE);
> > - }
> > + for (i = 0; i < chip->rmh.stat_len; ++i)
>
> Judging from the previous lines, the access over MAX_STREAM_BUFFER
> might be unsafe. So I guess a more safer change would be something
> like:
>
> for (i = 0; i < MAX_STREAM_BUFFER && chip->rmh.stat_len; ++i)
&& i < chip->rmh.stat_len
TBH, I'd prefer to just delete all this code since it used be ifdef 0.
But I'll resend as you have suggested.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ALSA: pci: lx6464es: fix a debug loop
@ 2023-01-26 16:39 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2023-01-26 16:39 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel, kernel-janitors, Takashi Iwai, Maxime Ripard
On Thu, Jan 26, 2023 at 01:53:01PM +0100, Takashi Iwai wrote:
> On Thu, 26 Jan 2023 10:30:02 +0100,
> Dan Carpenter wrote:
> >
> > This loop accidentally reuses the "i" iterator for both the inside and
> > the outside loop. The value of MAX_STREAM_BUFFER is 5. I believe that
> > chip->rmh.stat_len is in the 2-12 range. If the value of .stat_len is
> > 4 or more then it will loop exactly one time, but if it's less then it
> > is a forever loop.
> >
> > Fixes: 8e6320064c33 ("ALSA: lx_core: Remove useless #if 0 .. #endif")
> > Signed-off-by: Dan Carpenter <error27@gmail.com>
> > ---
> > sound/pci/lx6464es/lx_core.c | 12 +++++-------
> > 1 file changed, 5 insertions(+), 7 deletions(-)
> >
> > diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c
> > index d3f58a3d17fb..7c1b380a54c0 100644
> > --- a/sound/pci/lx6464es/lx_core.c
> > +++ b/sound/pci/lx6464es/lx_core.c
> > @@ -493,13 +493,11 @@ int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture,
> > dev_dbg(chip->card->dev,
> > "CMD_08_ASK_BUFFERS: needed %d, freed %d\n",
> > *r_needed, *r_freed);
> > - for (i = 0; i < MAX_STREAM_BUFFER; ++i) {
> > - for (i = 0; i != chip->rmh.stat_len; ++i)
> > - dev_dbg(chip->card->dev,
> > - " stat[%d]: %x, %x\n", i,
> > - chip->rmh.stat[i],
> > - chip->rmh.stat[i] & MASK_DATA_SIZE);
> > - }
> > + for (i = 0; i < chip->rmh.stat_len; ++i)
>
> Judging from the previous lines, the access over MAX_STREAM_BUFFER
> might be unsafe. So I guess a more safer change would be something
> like:
>
> for (i = 0; i < MAX_STREAM_BUFFER && chip->rmh.stat_len; ++i)
&& i < chip->rmh.stat_len
TBH, I'd prefer to just delete all this code since it used be ifdef 0.
But I'll resend as you have suggested.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-01-26 16:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-26 9:30 [PATCH] ALSA: pci: lx6464es: fix a debug loop Dan Carpenter
2023-01-26 9:30 ` Dan Carpenter
2023-01-26 12:53 ` Takashi Iwai
2023-01-26 12:53 ` Takashi Iwai
2023-01-26 16:39 ` Dan Carpenter
2023-01-26 16:39 ` Dan Carpenter
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.