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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux