mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 1/1] dmaengine: acpi: Free resource list at appropriate time
@ 2026-06-17  9:14 Andy Shevchenko
  2026-06-17 20:52 ` Frank Li
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2026-06-17  9:14 UTC (permalink / raw)
  To: dmaengine, linux-kernel; +Cc: Vinod Koul, Frank Li, Andy Shevchenko

In one case we don't free resources when formally should, and
in the other we do unneeded "double free" (emptying an empty
list).

Both are not critical issues at all, they just make code robust
against any possible future changes in the flow.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/acpi-dma.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/acpi-dma.c b/drivers/dma/acpi-dma.c
index be73021ecbd6..b053a7f96f85 100644
--- a/drivers/dma/acpi-dma.c
+++ b/drivers/dma/acpi-dma.c
@@ -55,7 +55,7 @@ static int acpi_dma_parse_resource_group(const struct acpi_csrt_group *grp,
 
 	INIT_LIST_HEAD(&resource_list);
 	ret = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
-	if (ret <= 0)
+	if (ret < 0)
 		return 0;
 
 	list_for_each_entry(rentry, &resource_list, node) {
@@ -370,10 +370,11 @@ struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
 	INIT_LIST_HEAD(&resource_list);
 	ret = acpi_dev_get_resources(adev, &resource_list,
 				     acpi_dma_parse_fixed_dma, &pdata);
-	acpi_dev_free_resource_list(&resource_list);
 	if (ret < 0)
 		return ERR_PTR(ret);
 
+	acpi_dev_free_resource_list(&resource_list);
+
 	if (dma_spec->slave_id < 0 || dma_spec->chan_id < 0)
 		return ERR_PTR(-ENODEV);
 
-- 
2.50.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] dmaengine: acpi: Free resource list at appropriate time
  2026-06-17  9:14 [PATCH v1 1/1] dmaengine: acpi: Free resource list at appropriate time Andy Shevchenko
@ 2026-06-17 20:52 ` Frank Li
  2026-06-18  6:34   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Frank Li @ 2026-06-17 20:52 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: dmaengine, linux-kernel, Vinod Koul, Frank Li

On Wed, Jun 17, 2026 at 11:14:21AM +0200, Andy Shevchenko wrote:
> In one case we don't free resources when formally should, and
> in the other we do unneeded "double free" (emptying an empty
> list).
>
> Both are not critical issues at all, they just make code robust
> against any possible future changes in the flow.

what are you talking about, can use straight forward words.

You just move acpi_dev_free_resource_list() after check return value
of acpi_dev_get_resources().

>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/dma/acpi-dma.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/acpi-dma.c b/drivers/dma/acpi-dma.c
> index be73021ecbd6..b053a7f96f85 100644
> --- a/drivers/dma/acpi-dma.c
> +++ b/drivers/dma/acpi-dma.c
> @@ -55,7 +55,7 @@ static int acpi_dma_parse_resource_group(const struct acpi_csrt_group *grp,
>
>  	INIT_LIST_HEAD(&resource_list);
>  	ret = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
> -	if (ret <= 0)
> +	if (ret < 0)
>  		return 0;

Dose this change related with this patch?

Frank
>
>  	list_for_each_entry(rentry, &resource_list, node) {
> @@ -370,10 +370,11 @@ struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
>  	INIT_LIST_HEAD(&resource_list);
>  	ret = acpi_dev_get_resources(adev, &resource_list,
>  				     acpi_dma_parse_fixed_dma, &pdata);
> -	acpi_dev_free_resource_list(&resource_list);
>  	if (ret < 0)
>  		return ERR_PTR(ret);
>
> +	acpi_dev_free_resource_list(&resource_list);
> +
>  	if (dma_spec->slave_id < 0 || dma_spec->chan_id < 0)
>  		return ERR_PTR(-ENODEV);
>
> --
> 2.50.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] dmaengine: acpi: Free resource list at appropriate time
  2026-06-17 20:52 ` Frank Li
@ 2026-06-18  6:34   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2026-06-18  6:34 UTC (permalink / raw)
  To: Frank Li; +Cc: dmaengine, linux-kernel, Vinod Koul, Frank Li

On Wed, Jun 17, 2026 at 04:52:09PM -0400, Frank Li wrote:
> On Wed, Jun 17, 2026 at 11:14:21AM +0200, Andy Shevchenko wrote:
> > In one case we don't free resources when formally should, and
> > in the other we do unneeded "double free" (emptying an empty
> > list).
> >
> > Both are not critical issues at all, they just make code robust
> > against any possible future changes in the flow.
> 
> what are you talking about, can use straight forward words.
> 
> You just move acpi_dev_free_resource_list() after check return value
> of acpi_dev_get_resources().

Not really. There are _two_ cases. And while they are slightly different,
the solution is to make them behave in the same ways.

...

> >  	INIT_LIST_HEAD(&resource_list);
> >  	ret = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
> > -	if (ret <= 0)
> > +	if (ret < 0)
> >  		return 0;
> 
> Dose this change related with this patch?

Yes. It's mentioned in the very first part of the first sentence in the commit
message.

> >
> >  	list_for_each_entry(rentry, &resource_list, node) {
> > @@ -370,10 +370,11 @@ struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
> >  	INIT_LIST_HEAD(&resource_list);
> >  	ret = acpi_dev_get_resources(adev, &resource_list,
> >  				     acpi_dma_parse_fixed_dma, &pdata);
> > -	acpi_dev_free_resource_list(&resource_list);
> >  	if (ret < 0)
> >  		return ERR_PTR(ret);
> >
> > +	acpi_dev_free_resource_list(&resource_list);
> > +
> >  	if (dma_spec->slave_id < 0 || dma_spec->chan_id < 0)
> >  		return ERR_PTR(-ENODEV);
> >
> > --
> > 2.50.1
> >

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-18  6:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-17  9:14 [PATCH v1 1/1] dmaengine: acpi: Free resource list at appropriate time Andy Shevchenko
2026-06-17 20:52 ` Frank Li
2026-06-18  6:34   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome