Skip to content

Commit

Permalink
staging: speakup: i18n.c: Fix leak in msg_set()
Browse files Browse the repository at this point in the history
If we end up returning -EINVAL from the function we will leak the
memory allocated to 'newstr' which has been allocated but not yet
assigned to anything.
Fix the leak by properly freeing the memory again before we return.

Signed-off-by: Jesper Juhl <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
jjuhl authored and gregkh committed Aug 14, 2012
1 parent 935d59f commit fafbc20
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/staging/speakup/i18n.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ ssize_t msg_set(enum msg_index_t index, char *text, size_t length)
&& index <= MSG_FORMATTED_END)
&& !fmt_validate(speakup_default_msgs[index],
newstr)) {
kfree(newstr);
return -EINVAL;
}
spk_lock(flags);
Expand Down

0 comments on commit fafbc20

Please sign in to comment.