diff mbox series

[7/9] ACPI: EC: Put the ACPI table after using it

Message ID 1588842561-32907-8-git-send-email-guohanjun@huawei.com (mailing list archive)
State Mainlined, archived
Headers show
Series ACPI: Call acpi_put_table() to release the ACPI table mappings | expand

Commit Message

Hanjun Guo May 7, 2020, 9:09 a.m. UTC
The embedded controller boot resources table needs to be
released after using it.

Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
---
 drivers/acpi/ec.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

Rafael J. Wysocki May 9, 2020, 9:11 a.m. UTC | #1
On Thursday, May 7, 2020 11:09:19 AM CEST Hanjun Guo wrote:
> The embedded controller boot resources table needs to be
> released after using it.
> 
> Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
> ---
>  drivers/acpi/ec.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
> index b4c0152e..281a9bf 100644
> --- a/drivers/acpi/ec.c
> +++ b/drivers/acpi/ec.c
> @@ -1784,12 +1784,15 @@ static void __init acpi_ec_ecdt_start(void)
>  
>  	status = acpi_get_handle(NULL, ecdt_ptr->id, &handle);
>  	if (ACPI_FAILURE(status))
> -		return;
> +		goto out;
>  

So to avoid adding a new label I would prefer

if (ACPI_SUCCESS(status)) {
	boot_ec->handle = handle;

	/* Add a special ACPI device object to represent the boot EC. */
	acpi_bus_register_early_device(ACPI_BUS_TYPE_ECDT_EC);
}

>  	boot_ec->handle = handle;
>  
>  	/* Add a special ACPI device object to represent the boot EC. */
>  	acpi_bus_register_early_device(ACPI_BUS_TYPE_ECDT_EC);
> +
> +out:
> +	acpi_put_table((struct acpi_table_header *)ecdt_ptr);
>  }
>
Rafael J. Wysocki May 9, 2020, 9:30 a.m. UTC | #2
On Saturday, May 9, 2020 11:11:26 AM CEST Rafael J. Wysocki wrote:
> On Thursday, May 7, 2020 11:09:19 AM CEST Hanjun Guo wrote:
> > The embedded controller boot resources table needs to be
> > released after using it.
> > 
> > Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
> > ---
> >  drivers/acpi/ec.c | 14 ++++++++++----
> >  1 file changed, 10 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
> > index b4c0152e..281a9bf 100644
> > --- a/drivers/acpi/ec.c
> > +++ b/drivers/acpi/ec.c
> > @@ -1784,12 +1784,15 @@ static void __init acpi_ec_ecdt_start(void)
> >  
> >  	status = acpi_get_handle(NULL, ecdt_ptr->id, &handle);
> >  	if (ACPI_FAILURE(status))
> > -		return;
> > +		goto out;
> >  
> 
> So to avoid adding a new label I would prefer
> 
> if (ACPI_SUCCESS(status)) {
> 	boot_ec->handle = handle;
> 
> 	/* Add a special ACPI device object to represent the boot EC. */
> 	acpi_bus_register_early_device(ACPI_BUS_TYPE_ECDT_EC);
> }
> 
> >  	boot_ec->handle = handle;
> >  
> >  	/* Add a special ACPI device object to represent the boot EC. */
> >  	acpi_bus_register_early_device(ACPI_BUS_TYPE_ECDT_EC);
> > +
> > +out:
> > +	acpi_put_table((struct acpi_table_header *)ecdt_ptr);
> >  }
> >  

I've made the above change manually and applied the whole series as 5.8
material.

Thanks!
Hanjun Guo May 9, 2020, 9:47 a.m. UTC | #3
On 2020/5/9 17:30, Rafael J. Wysocki wrote:
> On Saturday, May 9, 2020 11:11:26 AM CEST Rafael J. Wysocki wrote:
>> On Thursday, May 7, 2020 11:09:19 AM CEST Hanjun Guo wrote:
>>> The embedded controller boot resources table needs to be
>>> released after using it.
>>>
>>> Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
>>> ---
>>>   drivers/acpi/ec.c | 14 ++++++++++----
>>>   1 file changed, 10 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
>>> index b4c0152e..281a9bf 100644
>>> --- a/drivers/acpi/ec.c
>>> +++ b/drivers/acpi/ec.c
>>> @@ -1784,12 +1784,15 @@ static void __init acpi_ec_ecdt_start(void)
>>>   
>>>   	status = acpi_get_handle(NULL, ecdt_ptr->id, &handle);
>>>   	if (ACPI_FAILURE(status))
>>> -		return;
>>> +		goto out;
>>>   
>>
>> So to avoid adding a new label I would prefer
>>
>> if (ACPI_SUCCESS(status)) {
>> 	boot_ec->handle = handle;
>>
>> 	/* Add a special ACPI device object to represent the boot EC. */
>> 	acpi_bus_register_early_device(ACPI_BUS_TYPE_ECDT_EC);
>> }
>>
>>>   	boot_ec->handle = handle;
>>>   
>>>   	/* Add a special ACPI device object to represent the boot EC. */
>>>   	acpi_bus_register_early_device(ACPI_BUS_TYPE_ECDT_EC);
>>> +
>>> +out:
>>> +	acpi_put_table((struct acpi_table_header *)ecdt_ptr);
>>>   }
>>>   
> 
> I've made the above change manually and applied the whole series as 5.8
> material.

Thank you very much!
diff mbox series

Patch

diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index b4c0152e..281a9bf 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -1784,12 +1784,15 @@  static void __init acpi_ec_ecdt_start(void)
 
 	status = acpi_get_handle(NULL, ecdt_ptr->id, &handle);
 	if (ACPI_FAILURE(status))
-		return;
+		goto out;
 
 	boot_ec->handle = handle;
 
 	/* Add a special ACPI device object to represent the boot EC. */
 	acpi_bus_register_early_device(ACPI_BUS_TYPE_ECDT_EC);
+
+out:
+	acpi_put_table((struct acpi_table_header *)ecdt_ptr);
 }
 
 /*
@@ -1891,12 +1894,12 @@  void __init acpi_ec_ecdt_probe(void)
 		 * Asus X50GL:
 		 * https://bugzilla.kernel.org/show_bug.cgi?id=11880
 		 */
-		return;
+		goto out;
 	}
 
 	ec = acpi_ec_alloc();
 	if (!ec)
-		return;
+		goto out;
 
 	if (EC_FLAGS_CORRECT_ECDT) {
 		ec->command_addr = ecdt_ptr->data.address;
@@ -1922,13 +1925,16 @@  void __init acpi_ec_ecdt_probe(void)
 	ret = acpi_ec_setup(ec, NULL);
 	if (ret) {
 		acpi_ec_free(ec);
-		return;
+		goto out;
 	}
 
 	boot_ec = ec;
 	boot_ec_is_ecdt = true;
 
 	pr_info("Boot ECDT EC used to handle transactions\n");
+
+out:
+	acpi_put_table((struct acpi_table_header *)ecdt_ptr);
 }
 
 #ifdef CONFIG_PM_SLEEP