summaryrefslogtreecommitdiff
path: root/drivers/staging/speakup/kobjects.c
diff options
context:
space:
mode:
authorChristopher Brannon <chris@the-brannons.com>2013-09-11 10:05:27 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-17 07:47:46 -0700
commitfaf487b62059cd837c393dd42b30996da49fc157 (patch)
treeb5023dc0891c54fa9000ce01450d8d5a9e55abcd /drivers/staging/speakup/kobjects.c
parentb71600bb4bc8591c9bc4234cc12b51d521444b1c (diff)
staging: speakup: kobjects.c: Use correct values when changing voice.
When a new voice is selected, we set volume and pitch appropriate for the voice. We need to use the numeric index corresponding to the voice when indexing into the volume and pitch tables, rather than the raw user input that was used to select the voice. Note that using the raw input can also lead to an invalid memory read in the case of invalid or malicious user input. Signed-off-by: Christopher Brannon <chris@the-brannons.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/speakup/kobjects.c')
-rw-r--r--drivers/staging/speakup/kobjects.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
index 61a3f7a5eb6b..f31afa2cffb7 100644
--- a/drivers/staging/speakup/kobjects.c
+++ b/drivers/staging/speakup/kobjects.c
@@ -651,7 +651,10 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr,
* If voice was just changed, we might need to reset our default
* pitch and volume.
*/
- if (param->var_id == VOICE) {
+ if (param->var_id == VOICE && synth &&
+ (ret == 0 || ret == -ERESTART)) {
+ var_data = param->data;
+ value = var_data->u.n.value;
spk_reset_default_value("pitch", synth->default_pitch,
value);
spk_reset_default_value("vol", synth->default_vol,