linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Sudeep Holla <sudeep.holla@arm.com>
Cc: Jassi Brar <jaswinder.singh@linaro.org>,
	linux-kernel@vger.kernel.org,
	Jassi Brar <jassisinghbrar@gmail.com>
Subject: Re: [PATCH] mailbox: mailbox-test: set tdev->signal to NULL after freeing
Date: Mon, 6 Jun 2016 16:15:39 +0100	[thread overview]
Message-ID: <20160606151539.GD1525@dell> (raw)
In-Reply-To: <1464106324-25005-1-git-send-email-sudeep.holla@arm.com>

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

      parent reply	other threads:[~2016-06-06 15:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160606151539.GD1525@dell \
    --to=lee.jones@linaro.org \
    --cc=jassisinghbrar@gmail.com \
    --cc=jaswinder.singh@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sudeep.holla@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).