1. 13 Mar, 2024 1 commit
    • Jonathan Cameron's avatar
      of: Add cleanup.h based auto release via __free(device_node) markings · 9448e55d
      Jonathan Cameron authored
      The recent addition of scope based cleanup support to the kernel
      provides a convenient tool to reduce the chances of leaking reference
      counts where of_node_put() should have been called in an error path.
      
      This enables
      	struct device_node *child __free(device_node) = NULL;
      
      	for_each_child_of_node(np, child) {
      		if (test)
      			return test;
      	}
      
      with no need for a manual call of of_node_put().
      A following patch will reduce the scope of the child variable to the
      for loop, to avoid an issues with ordering of autocleanup, and make it
      obvious when this assigned a non NULL value.
      
      In this simple example the gains are small but there are some very
      complex error handling cases buried in these loops that will be
      greatly simplified by enabling early returns with out the need
      for this manual of_node_put() call.
      
      Note that there are coccinelle checks in
      scripts/coccinelle/iterators/for_each_child.cocci to detect a failure
      to call of_node_put(). This new approach does not cause false positives.
      Longer term we may want to add scripting to check this new approach is
      done correctly with no double of_node_put() calls being introduced due
      to the auto cleanup. It may also be useful to script finding places
      this new approach is useful.
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Reviewed-by: default avatarRob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20240225142714.286440-2-jic23@kernel.orgSigned-off-by: default avatarRob Herring <robh@kernel.org>
      9448e55d
  2. 12 Mar, 2024 1 commit
  3. 08 Mar, 2024 6 commits
  4. 07 Mar, 2024 3 commits
  5. 05 Mar, 2024 5 commits
  6. 04 Mar, 2024 2 commits
  7. 01 Mar, 2024 6 commits
  8. 26 Feb, 2024 1 commit
  9. 22 Feb, 2024 3 commits
  10. 13 Feb, 2024 8 commits
  11. 12 Feb, 2024 3 commits
  12. 06 Feb, 2024 1 commit