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]>
---
 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 <[email protected]>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

Reply via email to