powerpc/pseries/energy: Use OF accessor functions to read ibm,drc-indexes
authorGautham R. Shenoy <ego@linux.vnet.ibm.com>
Fri, 8 Mar 2019 15:33:24 +0000 (21:03 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Apr 2019 04:26:29 +0000 (06:26 +0200)
commitd7c00bbbfac42b1de08aba0130f2ece2be38c5aa
tree306c5f75ae061f5868fd166bb98b9f9d5af9a4fc
parent0603e3a9281debbb2ce8fcc19d4844686289d9b4
powerpc/pseries/energy: Use OF accessor functions to read ibm,drc-indexes

commit ce9afe08e71e3f7d64f337a6e932e50849230fc2 upstream.

In cpu_to_drc_index() in the case when FW_FEATURE_DRC_INFO is absent,
we currently use of_read_property() to obtain the pointer to the array
corresponding to the property "ibm,drc-indexes". The elements of this
array are of type __be32, but are accessed without any conversion to
the OS-endianness, which is buggy on a Little Endian OS.

Fix this by using of_property_read_u32_index() accessor function to
safely read the elements of the array.

Fixes: e83636ac3334 ("pseries/drc-info: Search DRC properties for CPU indexes")
Cc: stable@vger.kernel.org # v4.16+
Reported-by: Pavithra R. Prakash <pavrampu@in.ibm.com>
Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Reviewed-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
[mpe: Make the WARN_ON a WARN_ON_ONCE so it's not retriggerable]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/platforms/pseries/pseries_energy.c