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 <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>
1 parent eca0f1b commit 95f6580

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

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)