From: Mikhail Dmitrichenko <mdmitrichenko@astralinux.ru>
To: stable@vger.kernel.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Mikhail Dmitrichenko <mdmitrichenko@astralinux.ru>,
Sasha Levin <sashal@kernel.org>, Schspa Shi <schspa@gmail.com>,
Lucas Tsai <lucas_tsai@richtek.com>,
Sebastian Reichel <sre@kernel.org>,
Rhyland Klein <rklein@nvidia.com>,
Anton Vorontsov <anton@enomsg.org>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org,
Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: [PATCH 5.10/5.15 2/2] power: supply: core: fix supplied_from allocations
Date: Mon, 2 Nov 2026 14:12:32 +0300 [thread overview]
Message-ID: <20261102111233.383-3-mdmitrichenko@astralinux.ru> (raw)
In-Reply-To: <20261102111233.383-1-mdmitrichenko@astralinux.ru>
From: Lucas Tsai <lucas_tsai@richtek.com>
commit ba61aed9a34671222d1149acfc2f0179a9ce7e80 upstream.
If dts property power-supplies has multiple values, then accessing to
psy->supplied_from[i-1] in __power_supply_populate_supplied_from will
overrun supplied_from array.
Fixes: f6e0b081fb30 ("power_supply: Populate supplied_from hierarchy from the device tree")
Signed-off-by: Lucas Tsai <lucas_tsai@richtek.com>
Link: https://patch.msgid.link/20260609114403.3896073-1-lucas_tsai@richtek.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Mikhail Dmitrichenko <mdmitrichenko@astralinux.ru>
---
Backport fix for CVE-2026-74271
drivers/power/supply/power_supply_core.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index d63cd225d4d4..b6ade977d63c 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -260,18 +260,13 @@ static int power_supply_check_supplies(struct power_supply *psy)
if (cnt == 1)
return 0;
- /* All supplies found, allocate char ** array for filling */
- psy->supplied_from = devm_kzalloc(&psy->dev, sizeof(*psy->supplied_from),
+ /* All supplies found, allocate char * array for filling */
+ psy->supplied_from = devm_kcalloc(&psy->dev,
+ cnt - 1, sizeof(*psy->supplied_from),
GFP_KERNEL);
if (!psy->supplied_from)
return -ENOMEM;
- *psy->supplied_from = devm_kcalloc(&psy->dev,
- cnt - 1, sizeof(**psy->supplied_from),
- GFP_KERNEL);
- if (!*psy->supplied_from)
- return -ENOMEM;
-
return power_supply_populate_supplied_from(psy);
}
#else
--
2.43.0
prev parent reply other threads:[~2026-11-02 11:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 11:12 [PATCH 5.10/5.15 0/2] power: supply: Fix supplied_from allocation Mikhail Dmitrichenko
2026-11-02 11:12 ` [PATCH 5.10/5.15 1/2] power: supply: Fix typo in power_supply_check_supplies Mikhail Dmitrichenko
2026-11-02 11:12 ` Mikhail Dmitrichenko [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=20261102111233.383-3-mdmitrichenko@astralinux.ru \
--to=mdmitrichenko@astralinux.ru \
--cc=anton@enomsg.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lucas_tsai@richtek.com \
--cc=lvc-project@linuxtesting.org \
--cc=rklein@nvidia.com \
--cc=sashal@kernel.org \
--cc=schspa@gmail.com \
--cc=sebastian.reichel@collabora.com \
--cc=sre@kernel.org \
--cc=stable@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®