Skip to contentSkip to conversation

m68k: emu: fix invalid free in nfeth_cleanup()

PATCH In review Pavel Skripkin 2 participants 2 messages Jul 5, 2021 – Jul 6, 2021 m68k architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k: emu: fix invalid free in nfeth_cleanup()

In for loop all nfeth_dev array members should be freed, not only the first one. Freeing only first array member can cause double-free bug.

Fixes 9cd7b148312f ("m68k/atari: ARAnyM - Add support for network

access")

---
 arch/m68k/emu/nfeth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/m68k/emu/nfeth.c +2 -2
index d2875e32abfc..79e55421cfb1 100644
@@ -254,8 +254,8 @@ static void __exit nfeth_cleanup(void)
 
 	for (i = 0; i < MAX_UNIT; i++) {
 		if (nfeth_dev[i]) {
-			unregister_netdev(nfeth_dev[0]);
-			free_netdev(nfeth_dev[0]);
+			unregister_netdev(nfeth_dev[i]);
+			free_netdev(nfeth_dev[i]);
 		}
 	}
 	free_irq(nfEtherIRQ, nfeth_interrupt);
Signature · 1 line
2.32.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Pavel Skripkin

In for loop all nfeth_dev array members should be freed, not only the first one. Freeing only first array member can cause double-free bug.

Fixes 9cd7b148312f ("m68k/atari: ARAnyM - Add support for network

access")

i.e. will queue in the m68k for-v5.15 branch.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds