]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/pseries: Fix of_node_put() underflow during DLPAR remove
authorTyrel Datwyler <tyreld@linux.vnet.ibm.com>
Tue, 18 Apr 2017 00:21:40 +0000 (20:21 -0400)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 24 Apr 2017 14:24:59 +0000 (00:24 +1000)
commit396996cb7c00ab0b4f82ea9316ae4bd833546605
treed56137d1312d3d481d005c7338600b1213fa9872
parent678ce0972c4434f3b18260554e1d95dada233d30
powerpc/pseries: Fix of_node_put() underflow during DLPAR remove

Historically struct device_node references were tracked using a kref embedded as
a struct field. Commit f092332aeeee ("of: Make device nodes kobjects so they
show up in sysfs") (Mar 2014) refactored device_nodes to be kobjects such that
the device tree could by more simply exposed to userspace using sysfs.

Commit 7f94fe081420 ("of: device_node kobject lifecycle fixes") (Mar 2014)
followed up these changes to better control the kobject lifecycle and in
particular the referecne counting via of_node_get(), of_node_put(), and
of_node_init().

A result of this second commit was that it introduced an of_node_put() call when
a dynamic node is detached, in of_node_remove(), that removes the initial kobj
reference created by of_node_init().

Traditionally as the original dynamic device node user the pseries code had
assumed responsibilty for releasing this final reference in its platform
specific DLPAR detach code.

This patch fixes a refcount underflow introduced by commit 7f94fe0814, and
recently exposed by the upstreaming of the recount API.

Messages like the following are no longer seen in the kernel log with this
patch following DLPAR remove operations of cpus and pci devices.

  rpadlpar_io: slot PHB 72 removed
  refcount_t: underflow; use-after-free.
  ------------[ cut here ]------------
  WARNING: CPU: 5 PID: 3335 at lib/refcount.c:128 refcount_sub_and_test+0xf4/0x110

Fixes: 7f94fe081420 ("of: device_node kobject lifecycle fixes")
Cc: stable@vger.kernel.org # v3.15+
Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
[mpe: Make change log commit references more verbose]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/pseries/dlpar.c