Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1824725pxb; Mon, 13 Sep 2021 06:23:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZB+vUAb0d1SqDbIL0EuarI6yyiYhxniotHJDX7vILQAuZpvExJI0qcDxpC2XwpTHQTnBr X-Received: by 2002:a05:6e02:2199:: with SMTP id j25mr8575882ila.97.1631539428075; Mon, 13 Sep 2021 06:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631539428; cv=none; d=google.com; s=arc-20160816; b=Mu/suJPzpEXMr0h8OfI2WgRnlaMca2XnsLH9G85NNzWD7xvQfZA9y2F+Q0Zrc4yLVh MNBB1METHSRkLrWDF951UKYItt5GqcR94BvM0heK5deiwRu0yEZgekSSS6aAatAbhxQO MONqguTO5MwcXnQmz9y+nve3M6MUOcwX9Ly2aKdhiwTh+GAOIBU3Crc3k8d22g+l8+jt g4PrTdXg/eUZZYhpdwqh29Zvh84ptyMxO+CY+NY3nlutFHitKtFspUOPaQ1XtgiOgDS9 vUq5mi0NuXgbbrvoR5CcddZVgQIOlJc52PSHKQQH8cqE7fAAbemyo4qWWdzHa2TLhgbN aEJQ== 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=DVVaehMlKeoj58D7oaQhRZwwrQ5XdbAb631VitXH2FA=; b=StmiQAhtUv3QUIh+ipMzzRgREikB39nRmlwvqa3d2dfiEfP3AXc/iq0PvSISNkinf9 G+l1883ToOy+dG4EaHAD3PbSeWE8oJX7fqk4N9jYyDUv8Kdw0MEltVMf6ZRe8RgvG5Wn WL67pkGnv+OtzADL2KXZChvR3ibHQiFvQDtZpLNa1MjvVYuXHoPWuSr2fnWEtHX5xiy5 Z/go7Sty58UyrKmlgA1+x1+YpFyAjK/Db40fRSU5rEAkhWoo7HC3OQAY7+o/I0TGwTx9 QzGp7lIRyRcgALSCb1bTpnOfURv6zyHCgh7bkzcb8aCGIQhGXcp8cTcH/TI9buSbjOIx xmSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MPYLnfLx; 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 r2si6311125ila.178.2021.09.13.06.23.35; Mon, 13 Sep 2021 06:23:48 -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=MPYLnfLx; 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 S240981AbhIMNWS (ORCPT + 99 others); Mon, 13 Sep 2021 09:22:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:35054 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239126AbhIMNU4 (ORCPT ); Mon, 13 Sep 2021 09:20:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6BB10610CF; Mon, 13 Sep 2021 13:19:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539159; bh=NCFf8RWzGott2TRXF6zwPzRcpfyirjoi2qahamBaxn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MPYLnfLxvNWz/RYC68VXbS9Pd+8Q5l3AESTuFkcIRcue3Z8Hd/2bIEZEen0Ll6qO5 bSuQ9WpfNqCbN1kZp6ASmoAiR+bWZBVk057HdEl7C9H/16r3g62XY4asb1lgUGRC6k AD30BsgagO1X9cm/Fm3j3r8uYGmu0ULhINM62W3M= 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 5.4 031/144] m68k: emu: Fix invalid free in nfeth_cleanup() Date: Mon, 13 Sep 2021 15:13:32 +0200 Message-Id: <20210913131048.995563789@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131047.974309396@linuxfoundation.org> References: <20210913131047.974309396@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 a4ebd2445eda..e5831cd293d0 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.30.2