2023-05-18 04:26:39

by Sen Chu

[permalink] [raw]
Subject: [PATCH v2] spmi: mediatek: add device id check

Add device id check for spmi write API.

Signed-off-by: Sen Chu <[email protected]>
---
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(+)

diff --git a/drivers/spmi/spmi-mtk-pmif.c b/drivers/spmi/spmi-mtk-pmif.c
index b3c991e1ea40..78a96e00ed54 100644
--- a/drivers/spmi/spmi-mtk-pmif.c
+++ b/drivers/spmi/spmi-mtk-pmif.c
@@ -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);

--
2.18.0



Subject: Re: [PATCH v2] spmi: mediatek: add device id check

Il 18/05/23 06:07, Sen Chu ha scritto:
> Add device id check for spmi write API.
>
> Signed-off-by: Sen Chu <[email protected]>

Reviewed-by: AngeloGioacchino Del Regno <[email protected]>



2023-10-24 02:23:26

by Stephen Boyd

[permalink] [raw]
Subject: Re: [PATCH v2] spmi: mediatek: add device id check

Quoting Sen Chu (2023-05-17 21:07:29)
> Add device id check for spmi write API.
>
> Signed-off-by: Sen Chu <[email protected]>
> ---

Applied to spmi-next