Re: [PATCH] ACPI: only free map once in osl.c

From: Dmitry Safonov
Date: Thu Nov 21 2019 - 16:19:58 EST


Hi Francesco,

I believe, there's still an issue with your patch.

On Wed, 20 Nov 2019 at 05:50, Francesco Ruggeri <fruggeri@xxxxxxxxxx> wrote:
> @@ -472,10 +477,11 @@ void acpi_os_unmap_generic_address(struct acpi_generic_address *gas)
> mutex_unlock(&acpi_ioremap_lock);
> return;
> }
> - acpi_os_drop_map_ref(map);
> + refcount = acpi_os_drop_map_ref(map);
> mutex_unlock(&acpi_ioremap_lock);

Here comes acpi_os_get_iomem() increasing the refcount again.

>
> - acpi_os_map_cleanup(map);
> + if (!refcount)
> + acpi_os_map_cleanup(map);
> }
> EXPORT_SYMBOL(acpi_os_unmap_generic_address);

And you free the acpi_ioremap that's being used:

> static void acpi_os_map_cleanup(struct acpi_ioremap *map)
> {
> - if (!map->refcount) {
> - synchronize_rcu_expedited();
> - acpi_unmap(map->phys, map->virt);
> - kfree(map);
> - }
> + synchronize_rcu_expedited();
> + acpi_unmap(map->phys, map->virt);
> + kfree(map);
> }

Thanks,
Dmitry