public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@stgolabs.net>
To: Bhuvanesh_Surachari@mentor.com
Cc: tglx@linutronix.de, peterz@infradead.org, mingo@kernel.org,
	akpm@linux-foundation.org, linux@rasmusvillemoes.dk,
	viresh.kumar@linaro.org, luto@amacapital.net,
	bigeasy@linutronix.de, mtk.manpages@gmail.com,
	linux-kernel@vger.kernel.org, Andy Lowe <Andy_Lowe@mentor.com>
Subject: Re: [PATCH] futex: Prevent pi_state from double freeing in case of error
Date: Fri, 18 Dec 2015 06:55:34 -0800	[thread overview]
Message-ID: <20151218145534.GD17386@linux-uzut.site> (raw)
In-Reply-To: <1450428223-7655-1-git-send-email-Bhuvanesh_Surachari@mentor.com>

On Fri, 18 Dec 2015, Bhuvanesh_Surachari@mentor.com wrote:

>From: Bhuvanesh Surachari <bhuvanesh_surachari@mentor.com>
>
>In case of error from rt_mutex_start_proxy_lock pi_state is freed
>twice in futex_requeue function. Hence removing free_pi_state in
>else branch and branching to the location where pi_state is freed.

This reads weird.

Do note that free_pi_state is already protected against passing it a nil
pi_state, so this is merely cosmetic.

Hmm but yeah, looks legit. The cases were we free the pi_state on error
are when doing retry kind of paths, EDEADLK not being one of those cases.

>
>Signed-off-by: Bhuvanesh Surachari <Bhuvanesh_Surachari@mentor.com>
>Signed-off-by: Andy Lowe <Andy_Lowe@mentor.com>

This last SoB tag is incorrect, Andy Lowe is not carrying the patch for you.

>---
> kernel/futex.c |    1 -
> 1 file changed, 1 deletion(-)
>
>diff --git a/kernel/futex.c b/kernel/futex.c
>index 684d754..264b3f2 100644
>--- a/kernel/futex.c
>+++ b/kernel/futex.c
>@@ -1815,7 +1815,6 @@ retry_private:
> 			} else if (ret) {
> 				/* -EDEADLK */
> 				this->pi_state = NULL;
>-				free_pi_state(pi_state);
> 				goto out_unlock;
> 			}
> 		}


Nit but I think we also want to set pi_state to nil after freeing it
in out_unlock. That way this scenario would simply be goto out_unlock.

Thanks,
Davidlohr

  reply	other threads:[~2015-12-18 14:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-18  8:43 [PATCH] futex: Prevent pi_state from double freeing in case of error Bhuvanesh_Surachari
2015-12-18 14:55 ` Davidlohr Bueso [this message]
2015-12-19 18:24   ` Thomas Gleixner
2015-12-20  5:21     ` Darren Hart
2015-12-21 17:42       ` Davidlohr Bueso
2015-12-23 14:56     ` Bhuvanesh
2015-12-23 18:07       ` Thomas Gleixner
2015-12-18 23:08 ` Darren Hart

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=20151218145534.GD17386@linux-uzut.site \
    --to=dave@stgolabs.net \
    --cc=Andy_Lowe@mentor.com \
    --cc=Bhuvanesh_Surachari@mentor.com \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=viresh.kumar@linaro.org \
    /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