]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
ARM/imx/mmcd: Fix broken cpu hotplug handling
authorThomas Gleixner <tglx@linutronix.de>
Wed, 21 Dec 2016 19:19:48 +0000 (20:19 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Sun, 25 Dec 2016 09:47:40 +0000 (10:47 +0100)
commita051f220d6b9bf9367695e2c319ccc3712b631ee
tree61e7b4fe65aa4acbb088a528fc8d8abf98a4701c
parenta98d1a0ca6d3fd6197f18749972d4cc21195b724
ARM/imx/mmcd: Fix broken cpu hotplug handling

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.

- Installing instances after the state has been set up

- Removing the instance in the error path before freeing memory

- Removing the 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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Shawn Guo <shawnguo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Frank Li <frank.li@nxp.com>
Cc: Zhengyu Shen <zhengyu.shen@nxp.com>
Link: http://lkml.kernel.org/r/20161221192111.596204211@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/arm/mach-imx/mmdc.c