mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-01 10:42:11 +00:00
powercap: intel_rapl: Fix off by one in get_rpi()
The rp->priv->rpi array is either rpi_msr or rpi_tpmi which have
NR_RAPL_PRIMITIVES number of elements. Thus the > needs to be >=
to prevent an off by one access.
Fixes: 98ff639a72
("powercap: intel_rapl: Support per Interface primitive information")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Link: https://patch.msgid.link/86e3a059-504d-4795-a5ea-4a653f3b41f8@stanley.mountain
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
eca0f1b0bb
commit
95f6580352
@ -740,7 +740,7 @@ static struct rapl_primitive_info *get_rpi(struct rapl_package *rp, int prim)
|
||||
{
|
||||
struct rapl_primitive_info *rpi = rp->priv->rpi;
|
||||
|
||||
if (prim < 0 || prim > NR_RAPL_PRIMITIVES || !rpi)
|
||||
if (prim < 0 || prim >= NR_RAPL_PRIMITIVES || !rpi)
|
||||
return NULL;
|
||||
|
||||
return &rpi[prim];
|
||||
|
Loading…
Reference in New Issue
Block a user