staging: speakup_soft: Fix reading of init string
commit20ce58f23298e3184eb85838d00c08aa62d835d6
authorBen Hutchings <ben@decadent.org.uk>
Sun, 16 Sep 2012 03:18:50 +0000 (16 04:18 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 17 Oct 2012 02:48:30 +0000 (17 03:48 +0100)
tree23b718f2d0fb5b6aea7709f8c680895c3e4cb17e
parenta4d44b6bfa193d1b25d8fb72f6566c4556cad0d5
staging: speakup_soft: Fix reading of init string

commit 40fe4f89671fb3c7ded94190fb267402a38b0261 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/speakup/speakup_soft.c