staging: speakup_soft: Fix reading of init string
authorBen Hutchings <ben@decadent.org.uk>
Sun, 16 Sep 2012 03:18:50 +0000 (04:18 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Sep 2012 12:32:50 +0000 (05:32 -0700)
commit40fe4f89671fb3c7ded94190fb267402a38b0261
treee3bdee36bb982ea417e109ff92393e904ada0fa5
parent0c4a9f6e0ac55db62816bfa5e584ed807540a5ee
staging: speakup_soft: Fix reading of init string

softsynth_read() reads a character at a time from the init string;
when it finds the null terminator it sets the initialized flag but
then repeats the last character.

Additionally, if the read() buffer is not big enough for the init
string, the next read() will start reading from the beginning again.
So the caller may never progress to reading anything else.

Replace the simple initialized flag with the current position in
the init string, carried over between calls.  Switch to reading
real data once this reaches the null terminator.

(This assumes that the length of the init string can't change, which
seems to be the case.  Really, the string and position belong together
in a per-file private struct.)

Tested-by: Samuel Thibault <sthibault@debian.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/speakup/speakup_soft.c