Skip to contentSkip to conversation

pcm_plug: Clear plugins on all error conditions

PATCH Applied Takashi Iwai 2 participants 3 messages Oct 19, 2016 – Oct 20, 2016 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 4 lines · Michael Forney

Otherwise, they will linger after the error is returned (but pcm->setup == 0). Then, if the caller tries to clean up and call snd_pcm_close(), the assertion plug->gen.slave == plug->req_slave will fail.

The changes look OK, but could you give your sign-off?

thanks,

Takashi

Quoted 23 lines
---
 src/pcm/pcm_plug.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/pcm/pcm_plug.c +3 -1
index 5639b9e..266707b 100644
@@ -652,8 +652,10 @@ static int snd_pcm_plug_insert_plugins(snd_pcm_t *pcm,
 	       (plug->ttable && !plug->ttable_ok)) {
 		snd_pcm_t *new;
 		int err;
-		if (k >= sizeof(funcs)/sizeof(*funcs))
+		if (k >= sizeof(funcs)/sizeof(*funcs)) {
+			snd_pcm_plug_clear(pcm);
 			return -EINVAL;
+		}
 		err = funcs[k](pcm, &new, client, &p);
 		if (err < 0) {
 			snd_pcm_plug_clear(pcm);
Signature · 1 line
2.10.1
#2 lore raw

PATCH 1/1 pcm_plug: Clear plugins on all error conditions

Otherwise, they will linger after the error is returned (but pcm->setup == 0). Then, if the caller tries to clean up and call snd_pcm_close(), the assertion plug->gen.slave == plug->req_slave will fail.

---
 src/pcm/pcm_plug.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/pcm/pcm_plug.c +3 -1
index 5639b9e..266707b 100644
@@ -652,8 +652,10 @@ static int snd_pcm_plug_insert_plugins(snd_pcm_t *pcm,
 	       (plug->ttable && !plug->ttable_ok)) {
 		snd_pcm_t *new;
 		int err;
-		if (k >= sizeof(funcs)/sizeof(*funcs))
+		if (k >= sizeof(funcs)/sizeof(*funcs)) {
+			snd_pcm_plug_clear(pcm);
 			return -EINVAL;
+		}
 		err = funcs[k](pcm, &new, client, &p);
 		if (err < 0) {
 			snd_pcm_plug_clear(pcm);
Signature · 1 line
2.10.1
author Applied
#3 lore raw
Quoted 6 lines · Michael Forney

Otherwise, they will linger after the error is returned (but pcm->setup == 0). Then, if the caller tries to clean up and call snd_pcm_close(), the assertion plug->gen.slave == plug->req_slave will fail.

Applied, thanks.

Takashi