[PATCH v2] of: overlay: remove unused of_overlay_remove_all()
#AppliedFrom:Abdurrahman Hussain <abdurrahman@nexthop.ai>
Date:
Message-ID:<20261014-b4-of-overlay-remove-all-fix-v2-1-cf5ea2cc9dc3@nexthop.ai>
Patch:v2 · 1/1
Language:zh_CN
Patch-ID:b989388da107d4cc0e9d3750012ad533c79d512d
Files:
Documentation/devicetree/overlay-notes.rstDocumentation/translations/zh_CN/devicetree/overlay-notes.rstdrivers/of/overlay.cinclude/linux/of.hLinks:lore message ↗ · raw mail ↗
Patch content 4 changed files
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 callingfree_overlay_changeset(). Through the aliased pointer that zeroesovcs->id itself, so free_overlay_changeset()'s "ovcs->id > 0" guard isfalse and both idr_remove() and list_del() are skipped: theoverlay_changeset is kfree()d while still linked in ovcs_list andregistered in ovcs_idr. Rather than fix a helper nobody calls, remove it, along with its!CONFIG_OF_OVERLAY stub and the paragraph documenting it inoverlay-notes.rst and in the zh_CN translation. ovcs_list itself stays: overlay_removal_is_ok() still walks it to checkthat a changeset is topmost. Reported-by: Sashiko AI <sashiko-bot@kernel.org>Closes: https://lore.kernel.org/20260901014554.83A8D1F000E9@smtp.kernel.orgSuggested-by: Rob Herring <robh@kernel.org>Link: https://lore.kernel.org/all/20260928182658.GA185307-robh@kernel.org/Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>---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@nexthop.ai To: Rob Herring <robh@kernel.org>To: Krzysztof Kozlowski <krzk+dt@kernel.org>To: Conor Dooley <conor+dt@kernel.org>To: Alex Shi <alexs@kernel.org>To: Yanteng Si <si.yanteng@linux.dev>To: Dongliang Mu <dzm91@hust.edu.cn>To: Jonathan Corbet <corbet@lwn.net>To: Shuah Khan <skhan@linuxfoundation.org>To: Saravana Kannan <saravanak@kernel.org>Cc: devicetree@vger.kernel.orgCc: linux-kernel@vger.kernel.orgCc: linux-doc@vger.kernel.org--- 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.rstindex 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.rstindex 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.cindex 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.hindex 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: 30724547b221e0e670ddfef140fc7d816b2aaec6change-id: 20260917-b4-of-overlay-remove-all-fix-9fafc8104ea0 Best regards,-- Abdurrahman Hussain <abdurrahman@nexthop.ai>