提交 fafbc202 编写于 作者: J Jesper Juhl 提交者: Greg Kroah-Hartman

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: NJesper Juhl <jj@chaosbits.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 935d59ff
...@@ -555,6 +555,7 @@ ssize_t msg_set(enum msg_index_t index, char *text, size_t length) ...@@ -555,6 +555,7 @@ ssize_t msg_set(enum msg_index_t index, char *text, size_t length)
&& index <= MSG_FORMATTED_END) && index <= MSG_FORMATTED_END)
&& !fmt_validate(speakup_default_msgs[index], && !fmt_validate(speakup_default_msgs[index],
newstr)) { newstr)) {
kfree(newstr);
return -EINVAL; return -EINVAL;
} }
spk_lock(flags); spk_lock(flags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册