From: "Zhang, Rui" <rui.zhang@intel.com>
To: "dan.carpenter@linaro.org" <dan.carpenter@linaro.org>
Cc: "linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"rafael@kernel.org" <rafael@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] powercap: intel_rapl: Fix off by one in get_rpi()
Date: Wed, 21 Aug 2024 01:59:30 +0000 [thread overview]
Message-ID: <20dde1046dee254091dddb1833b265603bc1bcc1.camel@intel.com> (raw)
In-Reply-To: <86e3a059-504d-4795-a5ea-4a653f3b41f8@stanley.mountain>
On Tue, 2024-08-20 at 11:41 +0300, Dan Carpenter wrote:
> 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: 98ff639a7289 ("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>
thanks,
rui
> ---
> drivers/powercap/intel_rapl_common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/powercap/intel_rapl_common.c
> b/drivers/powercap/intel_rapl_common.c
> index 8b7a5a31e8c1..67aec73511a7 100644
> --- a/drivers/powercap/intel_rapl_common.c
> +++ b/drivers/powercap/intel_rapl_common.c
> @@ -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];
prev parent reply other threads:[~2024-08-21 1:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 8:41 Dan Carpenter
2024-08-20 19:44 ` Rafael J. Wysocki
2024-08-21 1:59 ` Zhang, Rui [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20dde1046dee254091dddb1833b265603bc1bcc1.camel@intel.com \
--to=rui.zhang@intel.com \
--cc=dan.carpenter@linaro.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®