* [PATCH] Input: amijoy - fix memory region leak on registration failure
@ 2026-11-07 16:01 Thorsten Blum
2026-11-08 0:18 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-11-07 16:01 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: Thorsten Blum, Dmitry Torokhov, linux-input, linux-kernel
If input_register_device() fails in amijoy_init(), release the memory
region for port i before cleaning up the previously registered ports.
Fixes: 127278ce2254 ("Input: joysticks - handle errors when registering input devices")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
drivers/input/joystick/amijoy.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/input/joystick/amijoy.c b/drivers/input/joystick/amijoy.c
index cdb2b8f15348..3c2357ba7dc3 100644
--- a/drivers/input/joystick/amijoy.c
+++ b/drivers/input/joystick/amijoy.c
@@ -132,6 +132,7 @@ static int __init amijoy_init(void)
err = input_register_device(amijoy_dev[i]);
if (err) {
input_free_device(amijoy_dev[i]);
+ release_mem_region(CUSTOM_PHYSADDR + 10 + i * 2, 2);
goto fail;
}
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input: amijoy - fix memory region leak on registration failure
2026-11-07 16:01 [PATCH] Input: amijoy - fix memory region leak on registration failure Thorsten Blum
@ 2026-11-08 0:18 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2026-11-08 0:18 UTC (permalink / raw)
To: Thorsten Blum; +Cc: linux-input, linux-kernel
Hi Thorsten,
On Sat, Nov 07, 2026 at 05:01:57PM +0100, Thorsten Blum wrote:
> If input_register_device() fails in amijoy_init(), release the memory
> region for port i before cleaning up the previously registered ports.
>
> Fixes: 127278ce2254 ("Input: joysticks - handle errors when registering input devices")
> Cc: stable@vger.kernel.org
...
> err = input_register_device(amijoy_dev[i]);
> if (err) {
> input_free_device(amijoy_dev[i]);
> + release_mem_region(CUSTOM_PHYSADDR + 10 + i * 2, 2);
> goto fail;
> }
Do we really need this in stable? It has been like this for 20 years,
and only affects an unlikely input_register_device() failure (basically
-ENOMEM during init) on Amiga hardware, so please drop Cc: stable.
Without the constraint of keeping the diff minimal for stable, could we
also clean up the error handling here instead of unwinding inline (and
out of order relative to input_allocate_device() / request_mem_region())?
Either add cascading err_release_mem / err_free_dev labels before the
unregister loop so unwinding happens in reverse order without repeating
input_free_device(), or factor per-port initialization out into a small
amijoy_setup_port() helper.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-08 0:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-07 16:01 [PATCH] Input: amijoy - fix memory region leak on registration failure Thorsten Blum
2026-11-08 0:18 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox