Patch "of: Introduce for_each_*_child_of_node_scoped() to automate of_node_put() handling" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    of: Introduce for_each_*_child_of_node_scoped() to automate of_node_put() handling

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     of-introduce-for_each_-_child_of_node_scoped-to-auto.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 939e15092e5fc17c7ce793f075caf8fdfaccd93c
Author: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
Date:   Sun Feb 25 14:27:12 2024 +0000

    of: Introduce for_each_*_child_of_node_scoped() to automate of_node_put() handling
    
    [ Upstream commit 34af4554fb0ce164e2c4876683619eb1e23848d4 ]
    
    To avoid issues with out of order cleanup, or ambiguity about when the
    auto freed data is first instantiated, do it within the for loop definition.
    
    The disadvantage is that the struct device_node *child variable creation
    is not immediately obvious where this is used.
    However, in many cases, if there is another definition of
    struct device_node *child; the compiler / static analysers will notify us
    that it is unused, or uninitialized.
    
    Note that, in the vast majority of cases, the _available_ form should be
    used and as code is converted to these scoped handers, we should confirm
    that any cases that do not check for available have a good reason not
    to.
    
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
    Reviewed-by: Rob Herring <robh@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240225142714.286440-3-jic23@xxxxxxxxxx
    Signed-off-by: Rob Herring <robh@xxxxxxxxxx>
    Stable-dep-of: afc954fd223d ("thermal: of: Fix OF node leak in thermal_of_trips_init() error path")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/linux/of.h b/include/linux/of.h
index 506e30e4c959c..2960e609ca05e 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -1373,10 +1373,23 @@ static inline int of_property_read_s32(const struct device_node *np,
 #define for_each_child_of_node(parent, child) \
 	for (child = of_get_next_child(parent, NULL); child != NULL; \
 	     child = of_get_next_child(parent, child))
+
+#define for_each_child_of_node_scoped(parent, child) \
+	for (struct device_node *child __free(device_node) =		\
+	     of_get_next_child(parent, NULL);				\
+	     child != NULL;						\
+	     child = of_get_next_child(parent, child))
+
 #define for_each_available_child_of_node(parent, child) \
 	for (child = of_get_next_available_child(parent, NULL); child != NULL; \
 	     child = of_get_next_available_child(parent, child))
 
+#define for_each_available_child_of_node_scoped(parent, child) \
+	for (struct device_node *child __free(device_node) =		\
+	     of_get_next_available_child(parent, NULL);			\
+	     child != NULL;						\
+	     child = of_get_next_available_child(parent, child))
+
 #define for_each_of_cpu_node(cpu) \
 	for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \
 	     cpu = of_get_next_cpu_node(cpu))




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux