Fri, Sep 27, 2024 at 01:21:07AM +0200, Javier Carrasco kirjoitti: > Switch to device_for_each_child_node_scoped() to simplify the code by > removing the need for calls to fwnode_handle_put() in the error path. > > This also prevents possible memory leaks if new error paths are added > without the required call to fwnode_handle_put(). ... > ret = fwnode_property_read_u32(child, "reg", ®); > - if (ret || reg >= NUM_LEDS) { > - fwnode_handle_put(child); > + if (ret || reg >= NUM_LEDS) > return ERR_PTR(ret ? : -EINVAL); > - } It's now two nested conditionals instead of two independent ones: if (ret) return ERR_PTR(ret); if (reg >= NUM_LEDS) return ERR_PTR(-EINVAL); I believe my wariant is much better to read, understand, and maintain. -- With Best Regards, Andy Shevchenko