tc3589x_device_init() may register the GPIO MFD child before registering the keypad child. If the GPIO child is registered successfully but the subsequent mfd_add_devices() call for the keypad fails, the function returns without removing the already registered GPIO device. Since tc3589x_remove() is not called after a failed probe, the GPIO platform device remains registered and is never released. Remove the MFD children when keypad registration fails so that any GPIO child registered by the earlier mfd_add_devices() call is properly unregistered. The issue was identified by a static analysis tool I developed and confirmed by manual review. Fixes: 09c730a488c3 ("input/tc3589x: add tc3589x keypad support") Cc: stable@vger.kernel.org Signed-off-by: Guangshuo Li --- drivers/mfd/tc3589x.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c index 2d4eb771e230..309c4db99c2c 100644 --- a/drivers/mfd/tc3589x.c +++ b/drivers/mfd/tc3589x.c @@ -303,6 +303,7 @@ static int tc3589x_device_init(struct tc3589x *tc3589x) 0, tc3589x->domain); if (ret) { dev_err(tc3589x->dev, "failed to keypad child\n"); + mfd_remove_devices(tc3589x->dev); return ret; } dev_info(tc3589x->dev, "added keypad block\n"); -- 2.43.0