All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] staging: speakup: fix synth caching when synth init fails
@ 2017-06-20 10:07 Okash Khawaja
  0 siblings, 0 replies; only message in thread
From: Okash Khawaja @ 2017-06-20 10:07 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Samuel Thibault, linux-kernel
  Cc: William Hubbs, Chris Brannon, Kirk Reiser, speakup, devel

synths[] array caches currently loaded synths. synth_add checks
synths[] before adding a new one. It however ignores the result of
do_synth_init. So when do_synth_init fails, the failed synth is still
cached. Since, as a result module loading fails too, synth_remove -
which is responsible for removing the cached synth - is never called.
Next time the failing synth is added again it succeeds because
synth_add finds it cached inside synths[].

This patch fixes this by caching a synth only after do_synth_init
succeeds.

Signed-off-by: Okash Khawaja <okash.khawaja@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

---
 drivers/staging/speakup/synth.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -445,10 +445,15 @@ int synth_add(struct spk_synth *in_synth
 		mutex_unlock(&spk_mutex);
 		return -1;
 	}
-	synths[i++] = in_synth;
-	synths[i] = NULL;
+
 	if (in_synth->startup)
 		status = do_synth_init(in_synth);
+
+	if (!status) {
+		synths[i++] = in_synth;
+		synths[i] = NULL;
+	}
+
 	mutex_unlock(&spk_mutex);
 	return status;
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-06-20 10:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-20 10:07 [patch] staging: speakup: fix synth caching when synth init fails Okash Khawaja

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.