Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2567586lkm; Mon, 20 Sep 2021 18:55:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpKwe+LZ6AhSIxsDSu1I4AKe4Hk+5C/b7qrtJ44TYLqfAreRY911KNmFn9VPPa6Mggfphc X-Received: by 2002:a6b:b242:: with SMTP id b63mr7642554iof.133.1632188944345; Mon, 20 Sep 2021 18:49:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188944; cv=none; d=google.com; s=arc-20160816; b=qVXFF89KbqmfKn8cs0PUovFL135Ek33D9oCtLRFRNjXhs461OnYIVLqPYNqjkP/xwP Zv/jnNRbGOeqFO5ZaBnSPk7VtK/OXVzorvZ4tc7Lp1TBqqaEbCJqS7CnzlcxM2Qq7yh1 JkQvavr2cvCfo8iiWjQCeDMIqYh0BFqavqMAzZR+88Jov7jpYTDaVC43yIVJvx5sGFfw Xogg/QX6M4/scII5oXiN+qnGp0ex4dqagDwKuECRwMpwcTSug4cVKD7DCVwR/eYgdZZs pgaPxT/P4xF3V8YrZllUoofI7NIPXVH4teHY2FUod0v6IXZpqWtJJm1GGlyIEQSsRugO feVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XafHOhG14nUZiI/D1ltVTZlJDffd9LPK3dhiNvQxJlM=; b=Ns8IkbwFlcxQNjARPAmsxxuPdFZ6dhrFX594qCFAlTgfVH7+oxwpKB5khpW+q2X/WW BhYm24RYIiaqEeJBK4wSXLQZRaL54qO6+xzXQWAO5tg6aMcvezc9EFLI+/PLYnnJh2GA cUc7xK0jKndIAHpv79+64ZU5pjKipc8iJIHP78dmJt/wyYJWxr6j71cqddkE+agy6CTZ iKB3xs4ZLljdPjZVwwIbNMwVU5Z6KvJYYIllJZ6qOU5qboAXlt7F3uM/pzt4+h17k8fO yBTYvMiChKI++2zF8dwENWVnvWL3Or9FjT/9/aBjt9/zwt3CR2LXttGUBb9k7vWVIZ/t CESw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=b26L+KVh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k17si15237362iow.29.2021.09.20.18.48.50; Mon, 20 Sep 2021 18:49:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=b26L+KVh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344908AbhITRhz (ORCPT + 99 others); Mon, 20 Sep 2021 13:37:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:42454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351091AbhITRfu (ORCPT ); Mon, 20 Sep 2021 13:35:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5A802615A7; Mon, 20 Sep 2021 17:06:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632157576; bh=l7385ZFdomGiFMyukTPaBhMpcELxzfHOSJdQJlm8wPg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b26L+KVh3CXgkK+IsbWGUyLbmIQURxje6cNZARzONR9XJpLMkARVmKrjKOBHsOoDM GxPu8H4HIFij72vbiVPIkZYXdwTTjsTdobT42NqmIUXOQEvrh+G4wXDz0Ky164qZrE RD3J0uhsmXL4sQhH0BHY7Q3YjAgxlfgpUXbGomS0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Skripkin , Geert Uytterhoeven , Sasha Levin Subject: [PATCH 4.19 054/293] m68k: emu: Fix invalid free in nfeth_cleanup() Date: Mon, 20 Sep 2021 18:40:16 +0200 Message-Id: <20210920163935.111700421@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163933.258815435@linuxfoundation.org> References: <20210920163933.258815435@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Skripkin [ Upstream commit 761608f5cf70e8876c2f0e39ca54b516bdcb7c12 ] In the for loop all nfeth_dev array members should be freed, not only the first one. Freeing only the first array member can cause double-free bugs and memory leaks. Fixes: 9cd7b148312f ("m68k/atari: ARAnyM - Add support for network access") Signed-off-by: Pavel Skripkin Link: https://lore.kernel.org/r/20210705204727.10743-1-paskripkin@gmail.com Signed-off-by: Geert Uytterhoeven Signed-off-by: Sasha Levin --- 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 e45ce4243aaa..76262dc40e79 100644 --- a/arch/m68k/emu/nfeth.c +++ b/arch/m68k/emu/nfeth.c @@ -258,8 +258,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.30.2