From: Stephen Boyd <sboyd@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Sen Chu <sen.chu@mediatek.com>,
linux-kernel@vger.kernel.org, patches@lists.linux.dev,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Subject: [PATCH 8/8] spmi: mediatek: add device id check
Date: Wed, 6 Dec 2023 15:17:31 -0800 [thread overview]
Message-ID: <20231206231733.4031901-9-sboyd@kernel.org> (raw)
In-Reply-To: <20231206231733.4031901-1-sboyd@kernel.org>
From: Sen Chu <sen.chu@mediatek.com>
Add device id check for spmi write API.
Signed-off-by: Sen Chu <sen.chu@mediatek.com>
Link: https://lore.kernel.org/r/20230518040729.8789-1-sen.chu@mediatek.com
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
---
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 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);
--
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/
https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git
prev parent reply other threads:[~2023-12-06 23:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-06 23:17 [PATCH 0/8] SPMI patches for the merge window Stephen Boyd
2023-12-06 23:17 ` [PATCH 1/8] spmi: mtk-pmif: Serialize PMIF status check and command submission Stephen Boyd
2023-12-15 16:12 ` Greg Kroah-Hartman
2023-12-06 23:17 ` [PATCH 2/8] spmi: mediatek: Fix UAF on device remove Stephen Boyd
2023-12-06 23:17 ` [PATCH 3/8] spmi: Introduce device-managed functions Stephen Boyd
2023-12-06 23:17 ` [PATCH 4/8] spmi: Use devm_spmi_controller_alloc() Stephen Boyd
2023-12-06 23:17 ` [PATCH 5/8] spmi: mtk-pmif: Reorder driver remove sequence Stephen Boyd
2023-12-06 23:17 ` [PATCH 6/8] spmi: hisi-spmi-controller: Use devm_spmi_controller_add() Stephen Boyd
2023-12-06 23:17 ` [PATCH 7/8] spmi: Return meaningful errors in spmi_controller_alloc() Stephen Boyd
2023-12-06 23:17 ` Stephen Boyd [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=20231206231733.4031901-9-sboyd@kernel.org \
--to=sboyd@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=sen.chu@mediatek.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.