* FAILED: Patch "mfd: core: Add locking around 'mfd_of_node_list'" failed to apply to 6.12-stable tree
@ 2026-03-01 1:22 Sasha Levin
2026-03-02 3:01 ` Doug Anderson
0 siblings, 1 reply; 4+ messages in thread
From: Sasha Levin @ 2026-03-01 1:22 UTC (permalink / raw)
To: stable, dianders; +Cc: Lee Jones
The patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 20117c92bcf9c11afd64d7481d8f94fdf410726e Mon Sep 17 00:00:00 2001
From: Douglas Anderson <dianders@chromium.org>
Date: Wed, 10 Dec 2025 11:30:03 -0800
Subject: [PATCH] mfd: core: Add locking around 'mfd_of_node_list'
Manipulating a list in the kernel isn't safe without some sort of
mutual exclusion. Add a mutex any time we access / modify
'mfd_of_node_list' to prevent possible crashes.
Cc: stable@vger.kernel.org
Fixes: 466a62d7642f ("mfd: core: Make a best effort attempt to match devices with the correct of_nodes")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patch.msgid.link/20251210113002.1.I6ceaca2cfb7eb25737012b166671f516696be4fd@changeid
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/mfd/mfd-core.c | 36 ++++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 6925bedddc80b..a30f93bf030aa 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -22,6 +22,7 @@
#include <linux/regulator/consumer.h>
static LIST_HEAD(mfd_of_node_list);
+static DEFINE_MUTEX(mfd_of_node_mutex);
struct mfd_of_node_entry {
struct list_head list;
@@ -104,9 +105,11 @@ static int mfd_match_of_node_to_dev(struct platform_device *pdev,
u64 of_node_addr;
/* Skip if OF node has previously been allocated to a device */
- list_for_each_entry(of_entry, &mfd_of_node_list, list)
- if (of_entry->np == np)
- return -EAGAIN;
+ scoped_guard(mutex, &mfd_of_node_mutex) {
+ list_for_each_entry(of_entry, &mfd_of_node_list, list)
+ if (of_entry->np == np)
+ return -EAGAIN;
+ }
if (!cell->use_of_reg)
/* No of_reg defined - allocate first free compatible match */
@@ -128,7 +131,8 @@ static int mfd_match_of_node_to_dev(struct platform_device *pdev,
of_entry->dev = &pdev->dev;
of_entry->np = np;
- list_add_tail(&of_entry->list, &mfd_of_node_list);
+ scoped_guard(mutex, &mfd_of_node_mutex)
+ list_add_tail(&of_entry->list, &mfd_of_node_list);
of_node_get(np);
device_set_node(&pdev->dev, of_fwnode_handle(np));
@@ -284,11 +288,13 @@ static int mfd_add_device(struct device *parent, int id,
if (cell->swnode)
device_remove_software_node(&pdev->dev);
fail_of_entry:
- list_for_each_entry_safe(of_entry, tmp, &mfd_of_node_list, list)
- if (of_entry->dev == &pdev->dev) {
- list_del(&of_entry->list);
- kfree(of_entry);
- }
+ scoped_guard(mutex, &mfd_of_node_mutex) {
+ list_for_each_entry_safe(of_entry, tmp, &mfd_of_node_list, list)
+ if (of_entry->dev == &pdev->dev) {
+ list_del(&of_entry->list);
+ kfree(of_entry);
+ }
+ }
fail_alias:
regulator_bulk_unregister_supply_alias(&pdev->dev,
cell->parent_supplies,
@@ -358,11 +364,13 @@ static int mfd_remove_devices_fn(struct device *dev, void *data)
if (cell->swnode)
device_remove_software_node(&pdev->dev);
- list_for_each_entry_safe(of_entry, tmp, &mfd_of_node_list, list)
- if (of_entry->dev == &pdev->dev) {
- list_del(&of_entry->list);
- kfree(of_entry);
- }
+ scoped_guard(mutex, &mfd_of_node_mutex) {
+ list_for_each_entry_safe(of_entry, tmp, &mfd_of_node_list, list)
+ if (of_entry->dev == &pdev->dev) {
+ list_del(&of_entry->list);
+ kfree(of_entry);
+ }
+ }
regulator_bulk_unregister_supply_alias(dev, cell->parent_supplies,
cell->num_parent_supplies);
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: FAILED: Patch "mfd: core: Add locking around 'mfd_of_node_list'" failed to apply to 6.12-stable tree
2026-03-01 1:22 FAILED: Patch "mfd: core: Add locking around 'mfd_of_node_list'" failed to apply to 6.12-stable tree Sasha Levin
@ 2026-03-02 3:01 ` Doug Anderson
2026-03-09 22:50 ` Doug Anderson
0 siblings, 1 reply; 4+ messages in thread
From: Doug Anderson @ 2026-03-02 3:01 UTC (permalink / raw)
To: Sasha Levin; +Cc: stable, Lee Jones
Sasha,
On Sat, Feb 28, 2026 at 5:22 PM Sasha Levin <sashal@kernel.org> wrote:
>
> The patch below does not apply to the 6.12-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
>
> Thanks,
> Sasha
>
> ------------------ original commit in Linus's tree ------------------
>
> From 20117c92bcf9c11afd64d7481d8f94fdf410726e Mon Sep 17 00:00:00 2001
> From: Douglas Anderson <dianders@chromium.org>
> Date: Wed, 10 Dec 2025 11:30:03 -0800
> Subject: [PATCH] mfd: core: Add locking around 'mfd_of_node_list'
Can you give any more details? I tried:
git checkout v6.12.74
git cherry-pick 20117c92bcf9 # ("mfd: core: Add locking around
'mfd_of_node_list'")
It seems to apply all the way back to 6.1 cleanly. NOTE: I didn't try
building with those older kernels. I can try if need be.
-Doug
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: FAILED: Patch "mfd: core: Add locking around 'mfd_of_node_list'" failed to apply to 6.12-stable tree
2026-03-02 3:01 ` Doug Anderson
@ 2026-03-09 22:50 ` Doug Anderson
2026-03-10 9:52 ` Sasha Levin
0 siblings, 1 reply; 4+ messages in thread
From: Doug Anderson @ 2026-03-09 22:50 UTC (permalink / raw)
To: Sasha Levin; +Cc: stable, Lee Jones
Hi,
On Sun, Mar 1, 2026 at 7:01 PM Doug Anderson <dianders@chromium.org> wrote:
>
> Sasha,
>
> On Sat, Feb 28, 2026 at 5:22 PM Sasha Levin <sashal@kernel.org> wrote:
> >
> > The patch below does not apply to the 6.12-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
> >
> > Thanks,
> > Sasha
> >
> > ------------------ original commit in Linus's tree ------------------
> >
> > From 20117c92bcf9c11afd64d7481d8f94fdf410726e Mon Sep 17 00:00:00 2001
> > From: Douglas Anderson <dianders@chromium.org>
> > Date: Wed, 10 Dec 2025 11:30:03 -0800
> > Subject: [PATCH] mfd: core: Add locking around 'mfd_of_node_list'
>
> Can you give any more details? I tried:
>
> git checkout v6.12.74
> git cherry-pick 20117c92bcf9 # ("mfd: core: Add locking around
> 'mfd_of_node_list'")
>
> It seems to apply all the way back to 6.1 cleanly. NOTE: I didn't try
> building with those older kernels. I can try if need be.
>
> -Doug
FWIW, I checked and v6.12.76 has the patch. So does the top of the 6.6
and 6.1 stable trees. So I guess this was a false positive report?
...or maybe you tried to apply it twice?
If someone wants this on 5.15, I think it's as easy as picking up
commit 8e88c61d6f34 ("mfd: core: Delete corresponding OF node entries
from list on MFD removal") as a stable dep.
If someone wants this on 5.10, we might need some extra backporting...
If someone is truly interested, let me know.
-Doug
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: FAILED: Patch "mfd: core: Add locking around 'mfd_of_node_list'" failed to apply to 6.12-stable tree
2026-03-09 22:50 ` Doug Anderson
@ 2026-03-10 9:52 ` Sasha Levin
0 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2026-03-10 9:52 UTC (permalink / raw)
To: Doug Anderson; +Cc: stable, Lee Jones
On Mon, Mar 09, 2026 at 03:50:33PM -0700, Doug Anderson wrote:
>Hi,
>
>On Sun, Mar 1, 2026 at 7:01 PM Doug Anderson <dianders@chromium.org> wrote:
>>
>> Sasha,
>>
>> On Sat, Feb 28, 2026 at 5:22 PM Sasha Levin <sashal@kernel.org> wrote:
>> >
>> > The patch below does not apply to the 6.12-stable tree.
>> > If someone wants it applied there, or to any other stable or longterm
>> > tree, then please email the backport, including the original git commit
>> > id to <stable@vger.kernel.org>.
>> >
>> > Thanks,
>> > Sasha
>> >
>> > ------------------ original commit in Linus's tree ------------------
>> >
>> > From 20117c92bcf9c11afd64d7481d8f94fdf410726e Mon Sep 17 00:00:00 2001
>> > From: Douglas Anderson <dianders@chromium.org>
>> > Date: Wed, 10 Dec 2025 11:30:03 -0800
>> > Subject: [PATCH] mfd: core: Add locking around 'mfd_of_node_list'
>>
>> Can you give any more details? I tried:
>>
>> git checkout v6.12.74
>> git cherry-pick 20117c92bcf9 # ("mfd: core: Add locking around
>> 'mfd_of_node_list'")
>>
>> It seems to apply all the way back to 6.1 cleanly. NOTE: I didn't try
>> building with those older kernels. I can try if need be.
>>
>> -Doug
>
>FWIW, I checked and v6.12.76 has the patch. So does the top of the 6.6
>and 6.1 stable trees. So I guess this was a false positive report?
>...or maybe you tried to apply it twice?
Nope, it was an issue with scripts on my end. Nothing needed for those trees :)
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-10 9:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-01 1:22 FAILED: Patch "mfd: core: Add locking around 'mfd_of_node_list'" failed to apply to 6.12-stable tree Sasha Levin
2026-03-02 3:01 ` Doug Anderson
2026-03-09 22:50 ` Doug Anderson
2026-03-10 9:52 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox