diff mbox series

[v1] drivers/i2c/muxes:Fix resource leaks in device_for_each_child_node() loops

Message ID 20230614112903.667-1-machel@vivo.com
State Rejected
Delegated to: Andi Shyti
Headers show
Series [v1] drivers/i2c/muxes:Fix resource leaks in device_for_each_child_node() loops | expand

Commit Message

王明-软件底层技术部 June 14, 2023, 11:28 a.m. UTC
The device_for_each_child_node loop in i2c-mux-gpio should
have fwnode_handle_put() before return which could avoid
resource leaks.This patch could fix this bug.

Signed-off-by: Wang Ming <machel@vivo.com>
---
 drivers/i2c/muxes/i2c-mux-gpio.c | 1 +
 1 file changed, 1 insertion(+)

--
2.25.1

Comments

Andi Shyti June 14, 2023, 11:43 a.m. UTC | #1
Hi Wang,

> diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
> index 5d5cbe013..90966de7a 100644
> --- a/drivers/i2c/muxes/i2c-mux-gpio.c
> +++ b/drivers/i2c/muxes/i2c-mux-gpio.c
> @@ -106,6 +106,7 @@ static int i2c_mux_gpio_probe_fw(struct gpiomux *mux,
>                 } else if (is_acpi_node(child)) {
>                         rc = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), values + i);
>                         if (rc)
> +                               fwnode_handle_put(child);
>                                 return dev_err_probe(dev, rc, "Cannot get address\n");
>                 }

please, read it again and tell me what's wrong :)

Andi
Krzysztof Kozlowski June 14, 2023, 12:02 p.m. UTC | #2
On 14/06/2023 13:43, Andi Shyti wrote:
> Hi Wang,
> 
>> diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
>> index 5d5cbe013..90966de7a 100644
>> --- a/drivers/i2c/muxes/i2c-mux-gpio.c
>> +++ b/drivers/i2c/muxes/i2c-mux-gpio.c
>> @@ -106,6 +106,7 @@ static int i2c_mux_gpio_probe_fw(struct gpiomux *mux,
>>                 } else if (is_acpi_node(child)) {
>>                         rc = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), values + i);
>>                         if (rc)
>> +                               fwnode_handle_put(child);
>>                                 return dev_err_probe(dev, rc, "Cannot get address\n");
>>                 }
> 
> please, read it again and tell me what's wrong :)


No, we can't tell what's wrong because:

> The contents of this message and any attachments may contain
> confidential and/or privileged information

:)

Wang,
Just run the sparse and smatch before posting patches.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
index 5d5cbe013..90966de7a 100644
--- a/drivers/i2c/muxes/i2c-mux-gpio.c
+++ b/drivers/i2c/muxes/i2c-mux-gpio.c
@@ -106,6 +106,7 @@  static int i2c_mux_gpio_probe_fw(struct gpiomux *mux,
                } else if (is_acpi_node(child)) {
                        rc = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), values + i);
                        if (rc)
+                               fwnode_handle_put(child);
                                return dev_err_probe(dev, rc, "Cannot get address\n");
                }