Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2318809pxb; Mon, 20 Sep 2021 18:41:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyG4vGEauf+vqvoLL0exalcZpLfxRhi5rINbIqtV/70M1rUx36BmFJqw+k3eSbo61A0xxfI X-Received: by 2002:a92:ce48:: with SMTP id a8mr19714565ilr.115.1632188478431; Mon, 20 Sep 2021 18:41:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188478; cv=none; d=google.com; s=arc-20160816; b=HyQhGvSf+9JAyCcJFGayfotxWBQWFIoJOy6HKy3ajdSc3CiMtmrAu0X5r/qiUQW5JY anYtWcnwnC/07y4eOkNorVKxcXgeqmRSI6w2QyflydnCTD1daiaQLEonXdoMVaW9bBg5 Qp67pvfgb/mJh5gLJ5rC2X2IeL44YBdSSMO9tu/o/vBM8QJr3vArt+2Zgd9N2ZePFhKf a0o71FMvJfYpWCh10sZ1yT3B9g6HoM86KfD0tt8Fyhh4qkErsC1OoZSTJuj4aDzcHO6h GhgRSOyGOaMAmxLIEm2m5of+ZuuKZYXkbT1GxPQcHu9NaJMJC0NdQqWM/Act7rvw5RV1 Lpvw== 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=UH3bsNyOhXZXKqiBgYaNpTwgxCrBJy+6bwcCSxOwH7g=; b=Vz76IIwzaYOk7M/YFwKLwMkMB4GBfsiNGaIu12ccOQGXs/AVmV86aR3pANLkWHg+Y2 oc47LUq370fX7NvfOq9rZaTz1v4/YV8VHcLiStSY5UUVUf//zyxMk8pG3J4pHA1DsJTD E//HAMbjjRVnlXpLIqxu6WrdZT985YhU3Bgyyk8d+Gkyq2zsNS9sY3fyv3S1xteZ0c3C wZ+m5l2bAHR7ur3L5vYAQP+qG/7TLmYIlBwztT7s5ddFJww8oXtdzI7Y4wu2kYRpqlKe c4kGFes9DzR/ZF7pb/UDLGeXN/SzEmRlCmEUcWvL6MA3wQuIZxu7Wx2qb7ujqwaMyNcl 4t5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uS7RwlN2; 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 e28si3996831ioc.25.2021.09.20.18.41.07; Mon, 20 Sep 2021 18:41:18 -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=uS7RwlN2; 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 S243850AbhITQsf (ORCPT + 99 others); Mon, 20 Sep 2021 12:48:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:36076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243457AbhITQrx (ORCPT ); Mon, 20 Sep 2021 12:47:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8F27D61177; Mon, 20 Sep 2021 16:46:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632156387; bh=561kO8v0wGDDZNoQK6dWoOnmZd0EodYRbwi5YlUICfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uS7RwlN2XklQTGsxG12MP4rGdEdQZ1T/2942oF6ymaEf6FqPIMBM67WfnfuoTCt5k ZLEjyU1BB3/lDg3XsHdeJ7rUBvC5gtfMKNEHU0WSTf67hdodMTqF8mTg15QGxshzwR 3NNpwPoQOwYzRbbTaPhYWXhfythUHfoUmG99Hnp4= 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.4 036/133] m68k: emu: Fix invalid free in nfeth_cleanup() Date: Mon, 20 Sep 2021 18:41:54 +0200 Message-Id: <20210920163913.821315471@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163912.603434365@linuxfoundation.org> References: <20210920163912.603434365@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 a0985fd088d1..7d695fc7a2d0 100644 --- a/arch/m68k/emu/nfeth.c +++ b/arch/m68k/emu/nfeth.c @@ -260,8 +260,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