Skip to content

Commit 95f6580

Browse files
Dan Carpenterrafaeljw
authored andcommitted
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: 98ff639 ("powercap: intel_rapl: Support per Interface primitive information") Signed-off-by: Dan Carpenter <[email protected]> Acked-by: Zhang Rui <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent eca0f1b commit 95f6580

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/powercap/intel_rapl_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ static struct rapl_primitive_info *get_rpi(struct rapl_package *rp, int prim)
740740
{
741741
struct rapl_primitive_info *rpi = rp->priv->rpi;
742742

743-
if (prim < 0 || prim > NR_RAPL_PRIMITIVES || !rpi)
743+
if (prim < 0 || prim >= NR_RAPL_PRIMITIVES || !rpi)
744744
return NULL;
745745

746746
return &rpi[prim];

0 commit comments

Comments
 (0)