From: Jesper Juhl Date: Tue, 7 Aug 2012 19:44:54 +0000 (+0200) Subject: staging: speakup: i18n.c: Fix leak in msg_set() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fafbc202cd3c6ff1dc77430176c4c41102ebbdfd;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git staging: speakup: i18n.c: Fix leak in msg_set() 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/speakup/i18n.c b/drivers/staging/speakup/i18n.c index ca01734d13c5..7c1658b971dc 100644 --- a/drivers/staging/speakup/i18n.c +++ b/drivers/staging/speakup/i18n.c @@ -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);