Re: [PATCH v2] gpio: aspeed: Fix potential coprocessor bank map leak
From: Bartosz Golaszewski
Date: Thu Nov 26 2026 - 09:11:04 EST
On Tue, Nov 24, 2026 at 09:58:32PM +0800, Guangshuo Li wrote:
> The coprocessor bank map is allocated lazily but is never freed when
> the GPIO controller is removed. Its only owner is the device-managed
> GPIO private data.
>
> Allocate the map with the controller's managed resources before
> registering the GPIO chip, so chip removal finishes before the map
> is freed. Round up the bank count to cover a partial last bank.
>
> This issue was found by our static analysis tool under development.
>
> Fixes: a7ca13826e47 ("gpio: aspeed: Add interfaces for co-processor to grab GPIOs")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
> ---
> Changes in v2:
> - Use a managed array allocation instead of a cleanup action.
> - Allocate before GPIO-chip registration so teardown callbacks finish
> before the bank map is freed.
> - Round up the array size to cover a partial last bank.
Please also include a lore link to the previous versions in the
changelog.
Bart