From nobody Thu Apr 2 18:46:09 2026 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3ACB426561A for ; Fri, 27 Mar 2026 02:42:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774579323; cv=none; b=VtzPzyECgcX/mcDpZWbJ10yBC2gqMPN0JssL8amu+TMKe0ZZR5oUiRaeo3i+Og1VD7uPy7nq4tkLO9l5p9A9bw7s6O/B37W04GUQTF5GGrTmWs+uSwl6Jj559P3QrCn9OqvQr2ZK+e2/j6lS3vwGsXrMTWW6gRAQgVR5dgp7H0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774579323; c=relaxed/simple; bh=71q7ZGqE6LfffEXcEoyZ6l9nHB435erjyjBsCPwnKO4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GOOWIzABXKYuIgqEK92VpfnYBA/1RykTtUs+Tah5R0tqBm8cm2cxkqrtwSPdJcqCR//6p2HXkLfkoy+1OrhgnrEh9OsP3ISM2hgVFjiqQbZxcVmCk2e4VIGrb/H1O4j0SVsGoK/Ml1+4WgjPUd3XoFSVAIMeL46VL/R6/mX7/Ys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HdTrKFp6; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HdTrKFp6" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-82c68339cf0so1716056b3a.0 for ; Thu, 26 Mar 2026 19:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774579321; x=1775184121; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qg6qyl8D6ZpxA5nd31mlMbDesea1EUpbYol+nQxv0kw=; b=HdTrKFp6xTj+/oTgmhhHi0QjDTXju81aqTbCHhVrAPUsY0htGYU7e9nfhQ+LWFKxuP BCI++SuJMVINDV4A+AtR98PYZCqxhX2BCvWgP0M7hda3HUmfw3yDP6ByoPfMianHf6TW Y8F+rbUUvGLW4etkV1N5U9QSnWQ6KdG+jZJaKXa2+2fnGbaYacUSrkU12p3TdbKhIEjj QftiOEX58Q3qbJ+shNcPbz+mN78hlVs6pVILzRSpTjUsk4SaQH9dVQueRw5x2wNl3LFg mxRUeXwG7Z5HaqOMZwCUIV2JufLQVoQZprGiZkADAwkvtlRd5saUVsopjs3oO+6Vr5Lq pPrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774579321; x=1775184121; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qg6qyl8D6ZpxA5nd31mlMbDesea1EUpbYol+nQxv0kw=; b=Ik2Zc7oMp+9vqbRGhs5zhtUCpS+4/mMzZBUx5q5AOEansjhnp252AfO5oPirWBqyLq qdOIc7X8jKgUeZES2atLc5c48EBy1vazVZNPm36b8lIXYM16y20Gi7kopYMzePll0i+m +AYt3uGaXpkzOX4gmjc6nMAL/OVeyUHRJTFLj3NoCLYk1sVESXsjvCNqmnKO2aZwIOzL 0UdZbg/tcJJJJO4ziKweOEjlt+NRIE6XgMA6uXe///lTR+DiSE8TULFIQ3QC/ujouBlq ANaxfUF7wG9Jn8N/JR3RuGd1u1LbSupg+REMNQHz+EE6/JuZ1JKA6bhOXIfjHm5jilTT f6Tg== X-Gm-Message-State: AOJu0YyHFwDs9hqGhqfeBzz4jKduY5l9KKEIrOAXAc+/gl3o+xpXWBeh cPs00e8ZBHu/ck/T0iZwliL3ztcyDSfmD5cMIvd6LDLJnd+GxfBwSUG2gqOUpDdD X-Gm-Gg: ATEYQzz5oFKA2uOUq+I7paopl7I6RU63XMd3U1ZqlwkHw9Zzg7Bdg+BmkPg/mpfOd2p 0DXRacgnszZNHytxzMc0lyfxXkK9HB7cMiQtMHhkxW4eL1Bmv3NjUvjYFz5SuHLuzBTPLfV/rZ3 /4EycgsE5WMVTI5F1T15kkBvvtvmnKik6DdSMmY/EnRq9HJM3x85F7Ga2wtdKrm5ME/qGPsVzLB cK/Khu4mCsLb4+1q1ws3PhUvPy4m9I0P2QV9SmsViOc178IdGhqp517Od8ETdnFpRGs2N+2+fs5 rMAek3oFUVsdsKZtXLYBD3izoA6ALYPpDb4T6RMmxnwitZtRRJM7nreVUASOYLCk+zvM93Y7fBv axcmrIKnsNpkJRg1EFmlScWEtLmFErzDVB0e0d/bPbegCLrIU5TXolSTWRvnNMb7QouiMur+WPK 68kp6TSXZnp+hZ+RHlENBPryJcaGc0PIon3gQpgxnxUYb0DF+/kkvpG9g= X-Received: by 2002:a05:6a00:1c81:b0:824:b304:2d1e with SMTP id d2e1a72fcca58-82c968762eamr539500b3a.8.1774579321196; Thu, 26 Mar 2026 19:42:01 -0700 (PDT) Received: from ryzen ([2601:644:8000:5b5d::8bd]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82c7d215658sm3812956b3a.21.2026.03.26.19.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 19:42:00 -0700 (PDT) From: Rosen Penev To: linux-kernel@vger.kernel.org Cc: Stephen Boyd Subject: [PATCH] spmi: use kzalloc_flex in main allocation Date: Thu, 26 Mar 2026 19:41:43 -0700 Message-ID: <20260327024143.6764-1-rosenp@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a flexible array member to avoid indexing past the struct. Signed-off-by: Rosen Penev --- drivers/spmi/spmi.c | 4 ++-- include/linux/spmi.h | 2 ++ 2 files changed, 4 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 de= vice *parent, if (WARN_ON(!parent)) return ERR_PTR(-EINVAL); =20 - ctrl =3D kzalloc(sizeof(*ctrl) + size, GFP_KERNEL); + ctrl =3D kzalloc_flex(*ctrl, priv, size); if (!ctrl) return ERR_PTR(-ENOMEM); =20 @@ -459,7 +459,7 @@ struct spmi_controller *spmi_controller_alloc(struct de= vice *parent, ctrl->dev.bus =3D &spmi_bus_type; ctrl->dev.parent =3D parent; ctrl->dev.of_node =3D parent->of_node; - spmi_controller_set_drvdata(ctrl, &ctrl[1]); + spmi_controller_set_drvdata(ctrl, ctrl->priv); =20 id =3D ida_alloc(&ctrl_ida, GFP_KERNEL); if (id < 0) { diff --git a/include/linux/spmi.h b/include/linux/spmi.h index 28e8c8bd3944..ddeeaee52ca7 100644 --- a/include/linux/spmi.h +++ b/include/linux/spmi.h @@ -76,6 +76,7 @@ void spmi_device_remove(struct spmi_device *sdev); * @cmd: sends a non-data command sequence on the SPMI bus. * @read_cmd: sends a register read command sequence on the SPMI bus. * @write_cmd: sends a register write command sequence on the SPMI bus. + * @priv: array of private data. */ struct spmi_controller { struct device dev; @@ -85,6 +86,7 @@ struct spmi_controller { u8 sid, u16 addr, u8 *buf, size_t len); int (*write_cmd)(struct spmi_controller *ctrl, u8 opcode, u8 sid, u16 addr, const u8 *buf, size_t len); + u8 priv[]; }; =20 static inline struct spmi_controller *to_spmi_controller(struct device *d) --=20 2.53.0