* [patch] staging: speakup: fix synth caching when synth init fails
@ Okash Khawaja
0 siblings, 0 replies; 4+ messages in thread
From: Okash Khawaja @ 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] 4+ messages in thread* [patch] staging: speakup: fix synth caching when synth init fails
@ Okash Khawaja
` Samuel Thibault
0 siblings, 1 reply; 4+ messages in thread
From: Okash Khawaja @ UTC (permalink / raw)
To: Samuel Thibault; +Cc: Speakup is a screen review system for Linux.
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>
---
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] 4+ messages in thread* Re: [patch] staging: speakup: fix synth caching when synth init fails
Okash Khawaja
@ ` Samuel Thibault
` Okash Khawaja
0 siblings, 1 reply; 4+ messages in thread
From: Samuel Thibault @ UTC (permalink / raw)
To: Okash Khawaja; +Cc: Speakup is a screen review system for Linux.
Okash Khawaja, on mar. 20 juin 2017 08:31:20 +0100, wrote:
> 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>
(I guess you have tested it)
> ---
> 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;
> }
>
--
Samuel
> C'est vrai. FreeBSD pourrait être bien s'il avait une licence
> correcte.
Oh, mon troll-ô-meter vient d'exploser...
-+- OR in Guide du linuxien pervers - "Bien regler son troll-ô-meter"
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [patch] staging: speakup: fix synth caching when synth init fails
` Samuel Thibault
@ ` Okash Khawaja
0 siblings, 0 replies; 4+ messages in thread
From: Okash Khawaja @ UTC (permalink / raw)
To: Samuel Thibault; +Cc: Speakup is a screen review system for Linux.
> On 20 Jun 2017, at 09:16, Samuel Thibault <samuel.thibault@ens-lyon.org> wrote:
>
> Okash Khawaja, on mar. 20 juin 2017 08:31:20 +0100, wrote:
>> 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>
>
> (I guess you have tested it)
Yes tested it working after the patch. No obvious regressions :)
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~ UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[patch] staging: speakup: fix synth caching when synth init fails Okash Khawaja
-- strict thread matches above, loose matches on Subject: below --
Okash Khawaja
` Samuel Thibault
` Okash Khawaja
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 read-only IMAP folder(s) and NNTP newsgroup(s).