diff mbox series

[v1,1/2] usb: typec: intel_pmc_mux: Don't leak the ACPI device reference count

Message ID 20230102202933.15968-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State Accepted
Commit c3194949ae8fcbe2b7e38670e7c6a5cfd2605edc
Headers show
Series [v1,1/2] usb: typec: intel_pmc_mux: Don't leak the ACPI device reference count | expand

Commit Message

Andy Shevchenko Jan. 2, 2023, 8:29 p.m. UTC
When acpi_dev_get_memory_resources() fails, the reference count is
left bumped. Drop it as it's done in the other error paths.

Fixes: 43d596e32276 ("usb: typec: intel_pmc_mux: Check the port status before connect")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/usb/typec/mux/intel_pmc_mux.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Heikki Krogerus Jan. 3, 2023, 9:28 a.m. UTC | #1
On Mon, Jan 02, 2023 at 10:29:32PM +0200, Andy Shevchenko wrote:
> When acpi_dev_get_memory_resources() fails, the reference count is
> left bumped. Drop it as it's done in the other error paths.
> 
> Fixes: 43d596e32276 ("usb: typec: intel_pmc_mux: Check the port status before connect")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/mux/intel_pmc_mux.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
> index fdbf3694e21f..87e2c9130607 100644
> --- a/drivers/usb/typec/mux/intel_pmc_mux.c
> +++ b/drivers/usb/typec/mux/intel_pmc_mux.c
> @@ -614,8 +614,10 @@ static int pmc_usb_probe_iom(struct pmc_usb *pmc)
>  
>  	INIT_LIST_HEAD(&resource_list);
>  	ret = acpi_dev_get_memory_resources(adev, &resource_list);
> -	if (ret < 0)
> +	if (ret < 0) {
> +		acpi_dev_put(adev);
>  		return ret;
> +	}
>  
>  	rentry = list_first_entry_or_null(&resource_list, struct resource_entry, node);
>  	if (rentry)
> -- 
> 2.35.1

thanks,
diff mbox series

Patch

diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
index fdbf3694e21f..87e2c9130607 100644
--- a/drivers/usb/typec/mux/intel_pmc_mux.c
+++ b/drivers/usb/typec/mux/intel_pmc_mux.c
@@ -614,8 +614,10 @@  static int pmc_usb_probe_iom(struct pmc_usb *pmc)
 
 	INIT_LIST_HEAD(&resource_list);
 	ret = acpi_dev_get_memory_resources(adev, &resource_list);
-	if (ret < 0)
+	if (ret < 0) {
+		acpi_dev_put(adev);
 		return ret;
+	}
 
 	rentry = list_first_entry_or_null(&resource_list, struct resource_entry, node);
 	if (rentry)