]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/pci-common: Fix refcount bug for 'phb->dn'
authorLiang He <windhl@126.com>
Sat, 2 Jul 2022 02:29:36 +0000 (10:29 +0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 5 Sep 2022 07:30:29 +0000 (17:30 +1000)
commitbf86f4c16ce83495a4fe74fd4a898fce7dcb7be7
tree77cc4d6282679ff0b17363ea491a8e13c5a1c7a2
parentfa2bdf1bffb9cf0bec4ee53a3601319987d89238
powerpc/pci-common: Fix refcount bug for 'phb->dn'

In pcibios_alloc_controller(), 'phb' is allocated and escaped into
global 'hose_list'. So we should call of_node_get() when a new reference
created into 'phb->dn'. And when phb is freed, we should call
of_node_put() on it.

NOTE: This function is called in the iteration of for_each_xx in
chrp_find_bridges() and pSeries_discover_phbs(). If there is no
of_node_get(), the object may be prematurely freed.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220702022936.266146-1-windhl@126.com
arch/powerpc/kernel/pci-common.c