* [PATCH] mailbox: mailbox-test: set tdev->signal to NULL after freeing
@ 2016-05-24 16:12 Sudeep Holla
2016-06-06 9:39 ` Sudeep Holla
2016-06-06 15:15 ` Lee Jones
0 siblings, 2 replies; 3+ messages in thread
From: Sudeep Holla @ 2016-05-24 16:12 UTC (permalink / raw)
To: Lee Jones, Jassi Brar; +Cc: linux-kernel, Sudeep Holla, Jassi Brar
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.
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Jassi Brar <jassisinghbrar@gmail.com>
Fixes: d1c2f87c9a8f ("mailbox: mailbox-test: Prevent memory leak")
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/mailbox/mailbox-test.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c
index 58d04726cdd7..9ca96e9db6bf 100644
--- a/drivers/mailbox/mailbox-test.c
+++ b/drivers/mailbox/mailbox-test.c
@@ -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;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mailbox: mailbox-test: set tdev->signal to NULL after freeing
2016-05-24 16:12 [PATCH] mailbox: mailbox-test: set tdev->signal to NULL after freeing Sudeep Holla
@ 2016-06-06 9:39 ` Sudeep Holla
2016-06-06 15:15 ` Lee Jones
1 sibling, 0 replies; 3+ messages in thread
From: Sudeep Holla @ 2016-06-06 9:39 UTC (permalink / raw)
To: Lee Jones, Jassi Brar; +Cc: Sudeep Holla, linux-kernel, Jassi Brar
Hi Jassi, Lee,
On 24/05/16 17:12, Sudeep Holla wrote:
> 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.
>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Jassi Brar <jassisinghbrar@gmail.com>
Can you review this ?
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mailbox: mailbox-test: set tdev->signal to NULL after freeing
2016-05-24 16:12 [PATCH] mailbox: mailbox-test: set tdev->signal to NULL after freeing Sudeep Holla
2016-06-06 9:39 ` Sudeep Holla
@ 2016-06-06 15:15 ` Lee Jones
1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2016-06-06 15:15 UTC (permalink / raw)
To: Sudeep Holla; +Cc: Jassi Brar, linux-kernel, Jassi Brar
On Tue, 24 May 2016, Sudeep Holla wrote:
> 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.
>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Jassi Brar <jassisinghbrar@gmail.com>
> Fixes: d1c2f87c9a8f ("mailbox: mailbox-test: Prevent memory leak")
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
> drivers/mailbox/mailbox-test.c | 1 +
> 1 file changed, 1 insertion(+)
Strange there isn't a kfree_and_null() call.
Patch looks okay to me though:
Acked-by: Lee Jones <lee.jones@linaro.org>
> diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c
> index 58d04726cdd7..9ca96e9db6bf 100644
> --- a/drivers/mailbox/mailbox-test.c
> +++ b/drivers/mailbox/mailbox-test.c
> @@ -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;
> }
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-06 15:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-24 16:12 [PATCH] mailbox: mailbox-test: set tdev->signal to NULL after freeing Sudeep Holla
2016-06-06 9:39 ` Sudeep Holla
2016-06-06 15:15 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).