From: Ingo Molnar <mingo@elte.hu>
To: Christian Engelmayer <christian.engelmayer@frequentis.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Mike Galbraith <efault@gmx.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] scheduler: access to variable out of scope in sched_slice()
Date: Wed, 17 Jun 2009 18:37:23 +0200 [thread overview]
Message-ID: <20090617163723.GB16128@elte.hu> (raw)
In-Reply-To: <20090616103512.0c846e51@frequentis.com>
* Christian Engelmayer <christian.engelmayer@frequentis.com> wrote:
> From: Christian Engelmayer <christian.engelmayer@frequentis.com>
>
> Access to local variable lw is aliased by usage of pointer load. Access to
> pointer load in calc_delta_mine() happens when lw is already out of scope.
>
> Signed-off-by: Christian Engelmayer <christian.engelmayer@frequentis.com>
> --
> Reported by static code analysis.
>
> --- linux-2.6.30/kernel/sched_fair.c.orig 2009-06-16 10:01:50.000000000 +0200
> +++ linux-2.6.30/kernel/sched_fair.c 2009-06-16 10:02:39.000000000 +0200
> @@ -430,12 +430,13 @@ static u64 sched_slice(struct cfs_rq *cf
>
> for_each_sched_entity(se) {
> struct load_weight *load;
> + struct load_weight lw;
>
> cfs_rq = cfs_rq_of(se);
> load = &cfs_rq->load;
>
> if (unlikely(!se->on_rq)) {
> - struct load_weight lw = cfs_rq->load;
> + lw = cfs_rq->load;
>
> update_load_add(&lw, se->load.weight);
> load = &lw;
Good one!
I suspect it doesnt matter in practice because GCC will just have
them all on the same stack frame?
Ingo
next prev parent reply other threads:[~2009-06-17 16:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-16 8:35 Christian Engelmayer
2009-06-17 16:37 ` Ingo Molnar [this message]
2009-06-17 16:39 ` [tip:sched/urgent] sched: Fix out of scope variable access " tip-bot for Christian Engelmayer
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=20090617163723.GB16128@elte.hu \
--to=mingo@elte.hu \
--cc=a.p.zijlstra@chello.nl \
--cc=christian.engelmayer@frequentis.com \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®