]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
powerpc/perf: Fix loop exit condition in nest_imc_event_init
authorAnju T Sudhakar <anju@linux.vnet.ibm.com>
Tue, 18 Dec 2018 06:20:41 +0000 (11:50 +0530)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commit749514224493c3e3b162b65921f9a3b26d2e35a3
tree5ba212c2c3205d27785af27c33accb4ee1a46b5d
parent398be188d2d4e577d187b3d190cebf9c8f1e8c42
powerpc/perf: Fix loop exit condition in nest_imc_event_init

BugLink: https://bugs.launchpad.net/bugs/1838700
[ Upstream commit 860b7d2286236170a36f94946d03ca9888d32571 ]

The data structure (i.e struct imc_mem_info) to hold the memory address
information for nest imc units is allocated based on the number of nodes
in the system.

nest_imc_event_init() traverse this struct array to calculate the memory
base address for the event-cpu. If we fail to find a match for the event
cpu's chip-id in imc_mem_info struct array, then the do-while loop will
iterate until we crash.

Fix this by changing the loop exit condition based on the number of
non zero vbase elements in the array, since the allocation is done for
nr_chips + 1.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 885dcd709ba91 ("powerpc/perf: Add nest IMC PMU support")
Signed-off-by: Anju T Sudhakar <anju@linux.vnet.ibm.com>
Reviewed-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/powerpc/perf/imc-pmu.c
arch/powerpc/platforms/powernv/opal-imc.c