aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSen Chu <[email protected]>2023-12-06 15:17:31 -0800
committerGreg Kroah-Hartman <[email protected]>2023-12-15 17:27:04 +0100
commitc49739235c426b05539589de2ffde2bbf71ae468 (patch)
treeb6aa8504a5686b333ce676b16c70ac309d868093
parent3ae3cf418a01203c33113e19cc1029ac434c96b5 (diff)
spmi: mediatek: add device id check
Add device id check for spmi write API. Signed-off-by: Sen Chu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r--drivers/spmi/spmi-mtk-pmif.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/spmi/spmi-mtk-pmif.c b/drivers/spmi/spmi-mtk-pmif.c
index cc660da6a037..5079442f8ea1 100644
--- a/drivers/spmi/spmi-mtk-pmif.c
+++ b/drivers/spmi/spmi-mtk-pmif.c
@@ -384,6 +384,12 @@ static int pmif_spmi_write_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
u32 data, wdata, cmd;
unsigned long flags;
+ /* 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);