[PATCH v2] of: overlay: remove unused of_overlay_remove_all()
From: Abdurrahman Hussain
Date: Wed Oct 14 2026 - 19:00:34 EST
of_overlay_remove_all() has no in-tree callers.
It is also subtly broken. It passes &ovcs->id to of_overlay_remove(),
which zeroes *ovcs_id once the changeset is reverted, before calling
free_overlay_changeset(). Through the aliased pointer that zeroes
ovcs->id itself, so free_overlay_changeset()'s "ovcs->id > 0" guard is
false and both idr_remove() and list_del() are skipped: the
overlay_changeset is kfree()d while still linked in ovcs_list and
registered in ovcs_idr.
Rather than fix a helper nobody calls, remove it, along with its
!CONFIG_OF_OVERLAY stub and the paragraph documenting it in
overlay-notes.rst and in the zh_CN translation.
ovcs_list itself stays: overlay_removal_is_ok() still walks it to check
that a changeset is topmost.
Reported-by: Sashiko AI <sashiko-bot@xxxxxxxxxx>
Closes: https://lore.kernel.org/20260901014554.83A8D1F000E9@xxxxxxxxxxxxxxx
Suggested-by: Rob Herring <robh@xxxxxxxxxx>
Link: https://lore.kernel.org/all/20260928182658.GA185307-robh@xxxxxxxxxx/
Signed-off-by: Abdurrahman Hussain <abdurrahman@xxxxxxxxxx>
---
Changes in v2:
- Drop the one-liner fix and just remove of_overlay_remove_all(), as
Rob suggested: it has no in-tree callers, so there is nothing to fix.
- Also drop the !CONFIG_OF_OVERLAY stub and the paragraph documenting
the function in overlay-notes.rst and in the zh_CN translation.
- No longer tagged for stable: a removal is not a backport candidate.
- Link to v1: https://patch.msgid.link/20260917-b4-of-overlay-remove-all-fix-v1-1-920441cecae2@xxxxxxxxxx
To: Rob Herring <robh@xxxxxxxxxx>
To: Krzysztof Kozlowski <krzk+dt@xxxxxxxxxx>
To: Conor Dooley <conor+dt@xxxxxxxxxx>
To: Alex Shi <alexs@xxxxxxxxxx>
To: Yanteng Si <si.yanteng@xxxxxxxxx>
To: Dongliang Mu <dzm91@xxxxxxxxxxx>
To: Jonathan Corbet <corbet@xxxxxxx>
To: Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx>
To: Saravana Kannan <saravanak@xxxxxxxxxx>
Cc: devicetree@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: linux-doc@xxxxxxxxxxxxxxx
---
Documentation/devicetree/overlay-notes.rst | 4 ----
.../zh_CN/devicetree/overlay-notes.rst | 3 ---
drivers/of/overlay.c | 23 ----------------------
include/linux/of.h | 6 ------
4 files changed, 36 deletions(-)
diff --git a/Documentation/devicetree/overlay-notes.rst b/Documentation/devicetree/overlay-notes.rst
index ba401ef850e7..f2bb1145bd9f 100644
--- a/Documentation/devicetree/overlay-notes.rst
+++ b/Documentation/devicetree/overlay-notes.rst
@@ -115,10 +115,6 @@ The API is quite easy to use.
previously created via the call to of_overlay_fdt_apply(). Removal of an
overlay changeset that is stacked by another will not be permitted.
-Finally, if you need to remove all overlays in one-go, just call
-of_overlay_remove_all() which will remove every single one in the correct
-order.
-
There is the option to register notifiers that get called on
overlay operations. See of_overlay_notifier_register/unregister and
enum of_overlay_notify_action for details.
diff --git a/Documentation/translations/zh_CN/devicetree/overlay-notes.rst b/Documentation/translations/zh_CN/devicetree/overlay-notes.rst
index ba5edd05dc1e..f1217ea2ff44 100644
--- a/Documentation/translations/zh_CN/devicetree/overlay-notes.rst
+++ b/Documentation/translations/zh_CN/devicetree/overlay-notes.rst
@@ -116,9 +116,6 @@ DT中的适当位置。在这种情况下,可以提供目标路径。通过标
2) 调用of_overlay_remove()来删除和清理先前通过调用of_overlay_fdt_apply()
而创建的覆盖变更集。不允许删除一个被另一个覆盖的覆盖变化集。
-最后,如果你需要一次性删除所有的覆盖,只需调用of_overlay_remove_all(),
-它将以正确的顺序删除每一个覆盖。
-
你可以选择注册在覆盖操作中被调用的通知器。详见
of_overlay_notifier_register/unregister和enum of_overlay_notify_action。
diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
index 83c56dd9b5d8..b2e1198fb41c 100644
--- a/drivers/of/overlay.c
+++ b/drivers/of/overlay.c
@@ -1282,26 +1282,3 @@ int of_overlay_remove(int *ovcs_id)
return ret;
}
EXPORT_SYMBOL_GPL(of_overlay_remove);
-
-/**
- * of_overlay_remove_all() - Reverts and frees all overlay changesets
- *
- * Removes all overlays from the system in the correct order.
- *
- * Return: 0 on success, or a negative error number
- */
-int of_overlay_remove_all(void)
-{
- struct overlay_changeset *ovcs, *ovcs_n;
- int ret;
-
- /* the tail of list is guaranteed to be safe to remove */
- list_for_each_entry_safe_reverse(ovcs, ovcs_n, &ovcs_list, ovcs_list) {
- ret = of_overlay_remove(&ovcs->id);
- if (ret)
- return ret;
- }
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(of_overlay_remove_all);
diff --git a/include/linux/of.h b/include/linux/of.h
index 20e4f752d5b6..c40d7d598875 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -1837,7 +1837,6 @@ struct of_overlay_notify_data {
int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size,
int *ovcs_id, const struct device_node *target_base);
int of_overlay_remove(int *ovcs_id);
-int of_overlay_remove_all(void);
int of_overlay_notifier_register(struct notifier_block *nb);
int of_overlay_notifier_unregister(struct notifier_block *nb);
@@ -1855,11 +1854,6 @@ static inline int of_overlay_remove(int *ovcs_id)
return -ENOTSUPP;
}
-static inline int of_overlay_remove_all(void)
-{
- return -ENOTSUPP;
-}
-
static inline int of_overlay_notifier_register(struct notifier_block *nb)
{
return 0;
---
base-commit: 30724547b221e0e670ddfef140fc7d816b2aaec6
change-id: 20260917-b4-of-overlay-remove-all-fix-9fafc8104ea0
Best regards,
--
Abdurrahman Hussain <abdurrahman@xxxxxxxxxx>