linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] m68k: emu: fix invalid free in nfeth_cleanup()
@ 2021-07-05 20:47 Pavel Skripkin
  2021-07-06  7:02 ` Geert Uytterhoeven
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Skripkin @ 2021-07-05 20:47 UTC (permalink / raw)
  To: geert, pstehlik, milan.jurik, schmitz
  Cc: linux-m68k, linux-kernel, 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")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
 arch/m68k/emu/nfeth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/m68k/emu/nfeth.c b/arch/m68k/emu/nfeth.c
index d2875e32abfc..79e55421cfb1 100644
--- a/arch/m68k/emu/nfeth.c
+++ b/arch/m68k/emu/nfeth.c
@@ -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);
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] m68k: emu: fix invalid free in nfeth_cleanup()
  2021-07-05 20:47 [PATCH] m68k: emu: fix invalid free in nfeth_cleanup() Pavel Skripkin
@ 2021-07-06  7:02 ` Geert Uytterhoeven
  0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2021-07-06  7:02 UTC (permalink / raw)
  To: Pavel Skripkin
  Cc: Petr Stehlik, milan.jurik, Michael Schmitz, linux-m68k,
	Linux Kernel Mailing List

On Mon, Jul 5, 2021 at 10:47 PM Pavel Skripkin <paskripkin@gmail.com> wrote:
> 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")
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
i.e. will queue in the m68k for-v5.15 branch.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-06  7:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05 20:47 [PATCH] m68k: emu: fix invalid free in nfeth_cleanup() Pavel Skripkin
2021-07-06  7:02 ` Geert Uytterhoeven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).