summaryrefslogtreecommitdiff
path: root/drivers/spmi/spmi.c
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2026-03-26 19:41:43 -0700
committerStephen Boyd <sboyd@kernel.org>2026-05-28 18:40:46 -0700
commit3443eec9c55d128064c83225a9111f1a1a37277a (patch)
tree1153752a8a3527869da905d85e795b8bfef8b17e /drivers/spmi/spmi.c
parent0c766f0f08ea681396814fd82eddd299da188625 (diff)
downloadlinux-next-3443eec9c55d128064c83225a9111f1a1a37277a.tar.gz
linux-next-3443eec9c55d128064c83225a9111f1a1a37277a.zip
spmi: use kzalloc_flex in main allocation
Add a flexible array member to avoid indexing past the struct. Signed-off-by: Rosen Penev <rosenp@gmail.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/spmi/spmi.c')
-rw-r--r--drivers/spmi/spmi.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/spmi/spmi.c b/drivers/spmi/spmi.c
index e889b129f3ac..57b7c0cb4240 100644
--- a/drivers/spmi/spmi.c
+++ b/drivers/spmi/spmi.c
@@ -450,7 +450,7 @@ struct spmi_controller *spmi_controller_alloc(struct device *parent,
if (WARN_ON(!parent))
return ERR_PTR(-EINVAL);
- ctrl = kzalloc(sizeof(*ctrl) + size, GFP_KERNEL);
+ ctrl = kzalloc_flex(*ctrl, priv, size);
if (!ctrl)
return ERR_PTR(-ENOMEM);
@@ -459,7 +459,7 @@ struct spmi_controller *spmi_controller_alloc(struct device *parent,
ctrl->dev.bus = &spmi_bus_type;
ctrl->dev.parent = parent;
ctrl->dev.of_node = parent->of_node;
- spmi_controller_set_drvdata(ctrl, &ctrl[1]);
+ spmi_controller_set_drvdata(ctrl, ctrl->priv);
id = ida_alloc(&ctrl_ida, GFP_KERNEL);
if (id < 0) {