Skip to contentSkip to conversation

spmi: mediatek: add device id check

PATCH Applied Sen Chu 3 participants 3 messages May 18, 2023 – Oct 24, 2023

Subsystems (2)
lore
Share & tools
lore

Sen Chu

author
#0 lore raw

PATCH v2 1/1 spmi: mediatek: add device id check

Add device id check for spmi write API.

---
Change in v1:
Fix: this should be unlikely(sid & ~0xf)
[Sen Chu <[email protected]>]
---

---
 drivers/spmi/spmi-mtk-pmif.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/spmi/spmi-mtk-pmif.c +6 -0
index b3c991e1ea40..78a96e00ed54 100644
@@ -378,6 +378,12 @@ static int pmif_spmi_write_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
 	int ret;
 	u32 data, cmd;
 
+	/* Check for argument validation. */
+	if (unlikely(sid & ~0xf)) {
+		dev_err(&ctrl->dev, "exceed the max slv id\n");
+		return -EINVAL;
+	}
+
 	if (len > 4) {
 		dev_err(&ctrl->dev, "pmif supports 1..4 bytes per trans, but:%zu requested", len);
 
Signature · 1 line
2.18.0