mailbox: mailbox-test: set tdev->signal to NULL after freeing
authorSudeep Holla <sudeep.holla@arm.com>
Tue, 24 May 2016 16:12:04 +0000 (17:12 +0100)
committerJassi Brar <jaswinder.singh@linaro.org>
Sun, 12 Jun 2016 09:43:04 +0000 (15:13 +0530)
tdev->signal is not set NULL after it's freed. This will cause random
exceptions when the stale pointer is accessed after tdev->signal is
freed. Also, since tdev->signal allocation is skipped the next time
it's written, this leads to continuous fault finally leading to the
total death of the system.

Fixes: d1c2f87c9a8f ("mailbox: mailbox-test: Prevent memory leak")
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
drivers/mailbox/mailbox-test.c

index 58d04726cdd7dc13f0faad15aeec89214ffce620..9ca96e9db6bfb137863250f8b27b2232fc1c449d 100644 (file)
@@ -133,6 +133,7 @@ static ssize_t mbox_test_message_write(struct file *filp,
 out:
        kfree(tdev->signal);
        kfree(tdev->message);
+       tdev->signal = NULL;
 
        return ret < 0 ? ret : count;
 }