diff mbox series

firmware: scmi: correct a validity check against power domain id

Message ID 20231107000547.182072-1-takahiro.akashi@linaro.org
State Accepted
Commit 4808d1633336a98f3c48a94a7e1fcd1e1030a324
Delegated to: Tom Rini
Headers show
Series firmware: scmi: correct a validity check against power domain id | expand

Commit Message

AKASHI Takahiro Nov. 7, 2023, 12:05 a.m. UTC
A power domain id on sandbox should be in the range from zero to
ARRAY_SIZE(scmi_pwdom) - 1. Correct the validity check logic.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Fixes: CID 467401
Fixes: CID 467405
---
 drivers/firmware/scmi/sandbox-scmi_agent.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Tom Rini Nov. 10, 2023, 4:21 p.m. UTC | #1
On Tue, Nov 07, 2023 at 09:05:47AM +0900, AKASHI Takahiro wrote:

> A power domain id on sandbox should be in the range from zero to
> ARRAY_SIZE(scmi_pwdom) - 1. Correct the validity check logic.
> 
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> Fixes: CID 467401
> Fixes: CID 467405

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/firmware/scmi/sandbox-scmi_agent.c b/drivers/firmware/scmi/sandbox-scmi_agent.c
index 9f5f497e0a6c..d13180962662 100644
--- a/drivers/firmware/scmi/sandbox-scmi_agent.c
+++ b/drivers/firmware/scmi/sandbox-scmi_agent.c
@@ -576,7 +576,7 @@  static int sandbox_scmi_pwd_attribs(struct udevice *dev, struct scmi_msg *msg)
 	domain_id = *(u32 *)msg->in_msg;
 	out = (struct scmi_pwd_attrs_out *)msg->out_msg;
 
-	if (domain_id > ARRAY_SIZE(scmi_pwdom)) {
+	if (domain_id >= ARRAY_SIZE(scmi_pwdom)) {
 		out->status = SCMI_NOT_FOUND;
 
 		return 0;
@@ -613,7 +613,7 @@  static int sandbox_scmi_pwd_state_set(struct udevice *dev, struct scmi_msg *msg)
 	in = (struct scmi_pwd_state_set_in *)msg->in_msg;
 	status = (s32 *)msg->out_msg;
 
-	if (in->domain_id > ARRAY_SIZE(scmi_pwdom)) {
+	if (in->domain_id >= ARRAY_SIZE(scmi_pwdom)) {
 		*status = SCMI_NOT_FOUND;
 
 		return 0;
@@ -653,7 +653,7 @@  static int sandbox_scmi_pwd_state_get(struct udevice *dev, struct scmi_msg *msg)
 	domain_id = *(u32 *)msg->in_msg;
 	out = (struct scmi_pwd_state_get_out *)msg->out_msg;
 
-	if (domain_id > ARRAY_SIZE(scmi_pwdom)) {
+	if (domain_id >= ARRAY_SIZE(scmi_pwdom)) {
 		out->status = SCMI_NOT_FOUND;
 
 		return 0;
@@ -686,7 +686,7 @@  static int sandbox_scmi_pwd_name_get(struct udevice *dev, struct scmi_msg *msg)
 	domain_id = *(u32 *)msg->in_msg;
 	out = (struct scmi_pwd_name_get_out *)msg->out_msg;
 
-	if (domain_id > ARRAY_SIZE(scmi_pwdom)) {
+	if (domain_id >= ARRAY_SIZE(scmi_pwdom)) {
 		out->status = SCMI_NOT_FOUND;
 
 		return 0;