Преглед изворни кода

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 <jj@chaosbits.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Jesper Juhl пре 13 година
родитељ
комит
fafbc202cd
1 измењених фајлова са 1 додато и 0 уклоњено
  1. 1 0
      drivers/staging/speakup/i18n.c

+ 1 - 0
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);