From: shawnguo@kernel.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: ARM: imx: mmdc: Fix completely broken cpu hotplug code
Date: Thu, 22 Dec 2016 08:57:08 +0800 [thread overview]
Message-ID: <20161222005705.GA11972@dragon> (raw)
In-Reply-To: <alpine.DEB.2.20.1612211928430.3424@nanos>
On Wed, Dec 21, 2016 at 07:32:06PM +0100, Thomas Gleixner wrote:
> On Wed, 21 Dec 2016, Thomas Gleixner wrote:
> > The cpu hotplug support of this perf driver is broken in several ways:
> >
> > 1) It adds a instance before setting up the state.
> >
> > 2) The state for the instance is different from the state of the
> > callback. It's just a randomly chosen state.
> >
> > 3) The instance registration is not error checked so nobody noticed that
> > the call can never succeed.
> >
> > 4) The state for the multi install callbacks is chosen randomly and
> > overwrites existing state. This is now prevented by the core code so the
> > call is guaranteed to fail.
> >
> > 5) The error exit path in the init function leaves the instance registered
> > and then frees the memory which contains the enqueued hlist node.
> >
> > 6) The remove function is removing the state and not the instance.
> >
> > Fix it by:
> >
> > - Setting up the state before adding instances. Use a dynamically allocated
> > state for it.
> >
> > - Install instances after the state has been set up
> >
> > - Remove the instance in the error path before freeing memory
> >
> > - Remove instance not the state in the driver remove callback
> >
> > While at is use raw_cpu_processor_id(), because cpu_processor_id() cannot
> > be used in preemptible context, and set the driver data after successful
> > registration of the pmu.
> >
> > Fixes: e76bdfd7403a ("ARM: imx: Added perf functionality to mmdc driver")
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Zhengyu Shen <zhengyu.shen@nxp.com>
> > Cc: Frank Li <frank.li@nxp.com>
> > Cc: Shawn Guo <shawnguo@kernel.org>
Acked-by: Shawn Guo <shawnguo@kernel.org>
>
> Shawn,
>
> as I have the final hotplug notifier removal pending here, which will break
> also the compilation of this driver, I would prefer to merge that through
> my tree before the removal patches to avoid build breakage.
Okay, thanks for taking care of it.
Shawn
WARNING: multiple messages have this Message-ID (diff)
From: Shawn Guo <shawnguo@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
LAK <linux-arm-kernel@lists.infradead.org>,
Zhengyu Shen <zhengyu.shen@nxp.com>, Frank Li <frank.li@nxp.com>,
Sebastian Sewior <bigeasy@linutronix.de>
Subject: Re: ARM: imx: mmdc: Fix completely broken cpu hotplug code
Date: Thu, 22 Dec 2016 08:57:08 +0800 [thread overview]
Message-ID: <20161222005705.GA11972@dragon> (raw)
In-Reply-To: <alpine.DEB.2.20.1612211928430.3424@nanos>
On Wed, Dec 21, 2016 at 07:32:06PM +0100, Thomas Gleixner wrote:
> On Wed, 21 Dec 2016, Thomas Gleixner wrote:
> > The cpu hotplug support of this perf driver is broken in several ways:
> >
> > 1) It adds a instance before setting up the state.
> >
> > 2) The state for the instance is different from the state of the
> > callback. It's just a randomly chosen state.
> >
> > 3) The instance registration is not error checked so nobody noticed that
> > the call can never succeed.
> >
> > 4) The state for the multi install callbacks is chosen randomly and
> > overwrites existing state. This is now prevented by the core code so the
> > call is guaranteed to fail.
> >
> > 5) The error exit path in the init function leaves the instance registered
> > and then frees the memory which contains the enqueued hlist node.
> >
> > 6) The remove function is removing the state and not the instance.
> >
> > Fix it by:
> >
> > - Setting up the state before adding instances. Use a dynamically allocated
> > state for it.
> >
> > - Install instances after the state has been set up
> >
> > - Remove the instance in the error path before freeing memory
> >
> > - Remove instance not the state in the driver remove callback
> >
> > While at is use raw_cpu_processor_id(), because cpu_processor_id() cannot
> > be used in preemptible context, and set the driver data after successful
> > registration of the pmu.
> >
> > Fixes: e76bdfd7403a ("ARM: imx: Added perf functionality to mmdc driver")
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Zhengyu Shen <zhengyu.shen@nxp.com>
> > Cc: Frank Li <frank.li@nxp.com>
> > Cc: Shawn Guo <shawnguo@kernel.org>
Acked-by: Shawn Guo <shawnguo@kernel.org>
>
> Shawn,
>
> as I have the final hotplug notifier removal pending here, which will break
> also the compilation of this driver, I would prefer to merge that through
> my tree before the removal patches to avoid build breakage.
Okay, thanks for taking care of it.
Shawn
next prev parent reply other threads:[~2016-12-22 0:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-21 18:21 ARM: imx: mmdc: Fix completely broken cpu hotplug code Thomas Gleixner
2016-12-21 18:21 ` Thomas Gleixner
2016-12-21 18:32 ` Thomas Gleixner
2016-12-21 18:32 ` Thomas Gleixner
2016-12-22 0:57 ` Shawn Guo [this message]
2016-12-22 0:57 ` Shawn Guo
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=20161222005705.GA11972@dragon \
--to=shawnguo@kernel.org \
--cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.