* [alsa-devel] [PATCH] mixer: Fix memory leak for more than 16 file descriptor case
@ 2020-01-07 15:18 David Fries
2020-01-08 8:50 ` Takashi Iwai
0 siblings, 1 reply; 5+ messages in thread
From: David Fries @ 2020-01-07 15:18 UTC (permalink / raw)
To: alsa-devel; +Cc: Takashi Iwai
Signed-off-by: David Fries <David@Fries.net>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
---
Added signed off.
I saw this when digging through the source code, wrote up a test case,
and verified with valgrind. I don't have that many sound cards so I
modified mixer.c to always take the conditional. alloca seemed like
the least effort way to fix this. Other thoughts were to test pfds !=
spfds and free, but given how little bytes would be allocated putting
on the stack seems reasonable.
I also created the github pull request 20.
https://github.com/alsa-project/alsa-lib/pull/20
src/mixer/mixer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c
index 82056474..b1af9945 100644
--- a/src/mixer/mixer.c
+++ b/src/mixer/mixer.c
@@ -767,7 +767,7 @@ int snd_mixer_wait(snd_mixer_t *mixer, int timeout)
if (count < 0)
return count;
if ((unsigned int) count > sizeof(spfds) / sizeof(spfds[0])) {
- pfds = malloc(count * sizeof(*pfds));
+ pfds = alloca(count * sizeof(*pfds));
if (!pfds)
return -ENOMEM;
err = snd_mixer_poll_descriptors(mixer, pfds,
--
2.11.0
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [alsa-devel] [PATCH] mixer: Fix memory leak for more than 16 file descriptor case
2020-01-07 15:18 [alsa-devel] [PATCH] mixer: Fix memory leak for more than 16 file descriptor case David Fries
@ 2020-01-08 8:50 ` Takashi Iwai
0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2020-01-08 8:50 UTC (permalink / raw)
To: David Fries; +Cc: alsa-devel
On Tue, 07 Jan 2020 16:18:10 +0100,
David Fries wrote:
>
> Signed-off-by: David Fries <David@Fries.net>
> Reviewed-by: Takashi Iwai <tiwai@suse.de>
Applied now. Thanks.
Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [alsa-devel] [PATCH] mixer: Fix memory leak for more than 16 file descriptor case
2020-01-07 13:03 ` Takashi Iwai
@ 2020-01-07 15:18 ` David Fries
0 siblings, 0 replies; 5+ messages in thread
From: David Fries @ 2020-01-07 15:18 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel
I realized that after I sent it, and I wasn't sure if that was going
to be the solution anyway. I sent another patch and added you as
reviewed by if that's okay.
On Tue, Jan 07, 2020 at 02:03:48PM +0100, Takashi Iwai wrote:
> On Mon, 06 Jan 2020 22:41:29 +0100,
> David Fries wrote:
> >
> > ---
> > I saw this when digging through the source code, wrote up a test case,
> > and verified with valgrind. I don't have that many sound cards so I
> > modified mixer.c to always take the conditional. alloca seemed like
> > the least effort way to fix this. Other thoughts were to test pfds !=
> > spfds and free, but given how little bytes would be allocated putting
> > on the stack seems reasonable.
>
> Looks good to me.
>
> Could you give your sign-off? It's not strictly needed for alsa-lib,
> but we prefer having it.
>
>
> thanks,
>
> Takashi
>
> >
> > I also created the github pull request 20.
> > https://github.com/alsa-project/alsa-lib/pull/20
> >
> > src/mixer/mixer.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c
> > index 82056474..b1af9945 100644
> > --- a/src/mixer/mixer.c
> > +++ b/src/mixer/mixer.c
> > @@ -767,7 +767,7 @@ int snd_mixer_wait(snd_mixer_t *mixer, int timeout)
> > if (count < 0)
> > return count;
> > if ((unsigned int) count > sizeof(spfds) / sizeof(spfds[0])) {
> > - pfds = malloc(count * sizeof(*pfds));
> > + pfds = alloca(count * sizeof(*pfds));
> > if (!pfds)
> > return -ENOMEM;
> > err = snd_mixer_poll_descriptors(mixer, pfds,
> > --
> > 2.11.0
> >
> > _______________________________________________
> > Alsa-devel mailing list
> > Alsa-devel@alsa-project.org
> > https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> >
--
David Fries <david@fries.net>
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [alsa-devel] [PATCH] mixer: Fix memory leak for more than 16 file descriptor case
2020-01-06 21:41 David Fries
@ 2020-01-07 13:03 ` Takashi Iwai
2020-01-07 15:18 ` David Fries
0 siblings, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2020-01-07 13:03 UTC (permalink / raw)
To: David Fries; +Cc: alsa-devel
On Mon, 06 Jan 2020 22:41:29 +0100,
David Fries wrote:
>
> ---
> I saw this when digging through the source code, wrote up a test case,
> and verified with valgrind. I don't have that many sound cards so I
> modified mixer.c to always take the conditional. alloca seemed like
> the least effort way to fix this. Other thoughts were to test pfds !=
> spfds and free, but given how little bytes would be allocated putting
> on the stack seems reasonable.
Looks good to me.
Could you give your sign-off? It's not strictly needed for alsa-lib,
but we prefer having it.
thanks,
Takashi
>
> I also created the github pull request 20.
> https://github.com/alsa-project/alsa-lib/pull/20
>
> src/mixer/mixer.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c
> index 82056474..b1af9945 100644
> --- a/src/mixer/mixer.c
> +++ b/src/mixer/mixer.c
> @@ -767,7 +767,7 @@ int snd_mixer_wait(snd_mixer_t *mixer, int timeout)
> if (count < 0)
> return count;
> if ((unsigned int) count > sizeof(spfds) / sizeof(spfds[0])) {
> - pfds = malloc(count * sizeof(*pfds));
> + pfds = alloca(count * sizeof(*pfds));
> if (!pfds)
> return -ENOMEM;
> err = snd_mixer_poll_descriptors(mixer, pfds,
> --
> 2.11.0
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [alsa-devel] [PATCH] mixer: Fix memory leak for more than 16 file descriptor case
@ 2020-01-06 21:41 David Fries
2020-01-07 13:03 ` Takashi Iwai
0 siblings, 1 reply; 5+ messages in thread
From: David Fries @ 2020-01-06 21:41 UTC (permalink / raw)
To: alsa-devel
---
I saw this when digging through the source code, wrote up a test case,
and verified with valgrind. I don't have that many sound cards so I
modified mixer.c to always take the conditional. alloca seemed like
the least effort way to fix this. Other thoughts were to test pfds !=
spfds and free, but given how little bytes would be allocated putting
on the stack seems reasonable.
I also created the github pull request 20.
https://github.com/alsa-project/alsa-lib/pull/20
src/mixer/mixer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c
index 82056474..b1af9945 100644
--- a/src/mixer/mixer.c
+++ b/src/mixer/mixer.c
@@ -767,7 +767,7 @@ int snd_mixer_wait(snd_mixer_t *mixer, int timeout)
if (count < 0)
return count;
if ((unsigned int) count > sizeof(spfds) / sizeof(spfds[0])) {
- pfds = malloc(count * sizeof(*pfds));
+ pfds = alloca(count * sizeof(*pfds));
if (!pfds)
return -ENOMEM;
err = snd_mixer_poll_descriptors(mixer, pfds,
--
2.11.0
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-01-08 8:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-07 15:18 [alsa-devel] [PATCH] mixer: Fix memory leak for more than 16 file descriptor case David Fries
2020-01-08 8:50 ` Takashi Iwai
-- strict thread matches above, loose matches on Subject: below --
2020-01-06 21:41 David Fries
2020-01-07 13:03 ` Takashi Iwai
2020-01-07 15:18 ` David Fries
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).