Re: [PATCH] soundwire: fix usages of device_get_named_child_node()

From: Markus Elfring
Date: Mon Apr 29 2024 - 07:32:14 EST



> Add fwnode_handle_put() to avoid leaked references.

calls?

Would you like to add the tag “Fixes” accordingly?



> +++ b/drivers/soundwire/mipi_disco.c

> @@ -236,8 +244,10 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
> dpn[i].num_channels,
> sizeof(*dpn[i].channels),
> GFP_KERNEL);
> - if (!dpn[i].channels)
> + if (!dpn[i].channels) {
> + fwnode_handle_put(node);
> return -ENOMEM;
> + }
>
> fwnode_property_read_u32_array(node,
> "mipi-sdw-channel-number-list",
> @@ -251,8 +261,10 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
> dpn[i].num_ch_combinations,
> sizeof(*dpn[i].ch_combinations),
> GFP_KERNEL);
> - if (!dpn[i].ch_combinations)
> + if (!dpn[i].ch_combinations) {
> + fwnode_handle_put(node);
> return -ENOMEM;
> + }
>
> fwnode_property_read_u32_array(node,
> "mipi-sdw-channel-combination-list",


* Would you like to complete the exception handling by using goto chains?

* How do you think about to increase the application of scope-based resource management?


Regards,
Markus