[PATCH] staging: speakup: i18n.c: Fix leak in msg_set()

From: Jesper Juhl
Date: Tue Aug 07 2012 - 15:44:48 EST


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 <jj@xxxxxxxxxxxxx>
---
drivers/staging/speakup/i18n.c | 1 +
1 file changed, 1 insertion(+)

Compile tested only.

diff --git a/drivers/staging/speakup/i18n.c b/drivers/staging/speakup/i18n.c
index ca01734..7c1658b 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);
--
1.7.11.4


--
Jesper Juhl <jj@xxxxxxxxxxxxx> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/