Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6231857rwn; Tue, 13 Sep 2022 00:33:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR4t982INEY5x61kwQhPhzIiQAHrx/toBwzqyZJD7TlbkFkUC4G3dONhKDleSFct+TlI+9in X-Received: by 2002:a05:6402:1f8c:b0:43e:8fab:76c with SMTP id c12-20020a0564021f8c00b0043e8fab076cmr25070967edc.126.1663054403488; Tue, 13 Sep 2022 00:33:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663054403; cv=none; d=google.com; s=arc-20160816; b=VAmgajk72Gk4ic+vQo6WtSqXLTxbGbdHqhRyYHFBkJ6rx8Br3yIMdrCe9E1GGy/h9K MpJfg+R0dqJ7sCK8+iqT58xE/Sx/YIyMpFUVViFLmb0Ga2sxBK7c5FHdWr+z/ZN//bXK KEHNZV2BfTZuUoW43XLd8qosO3KjIMUzsuk2tOvfAymWxYc40a9isMJ4nnoperk7Y8GX oh5VAfjbWH0ywUus3wv6/HKHiU1706ha0a+k9L7S//A0FHQTVfGzLFMS2Axlojxorw7K mNjVtBVk7fgcljf/UO2e/FAFrQ7FNCw85aEk04xcPKZXGUznmnfgDHSrM2Kx3AsZlFhd QIbw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=sFjDE3FMbVcbIWhkgqbv+dg2JpKyTv79I9Bu7jtu/kQ=; b=CpCKlrJWriD05GRHDcgCdxLw0T7q42Ti3bv09jhoZbowDiG35Jy0I9uS31MDoC2Aq5 8W1F+Fd7XwRIPhsqBfeHICoMJMKyUJAcmS2dgZvsbUyGIBGhWwlrB/8oDGriBgFyblbM OgbNquhyicKuYSheCpLMnarwp+T7mGzoH/WPEZMAyXLkmDPJjyb8vCVc9dWLbhO3Eamm olCWz7pVgoZbOqnYf2tWieMHwA4TUllztdUISGKOjComxlanTuAm/Wj09IDopb8Ow8LH GITVelJWFyY33xfn2d93jK/X2D4kEAEyKK5FBX0WjD5CL/eZqUUgqJjUdymepCyKPfGL Lp1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b="Rp0Ft/1F"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l23-20020a1709062a9700b00779c6c57dbfsi7346190eje.556.2022.09.13.00.32.56; Tue, 13 Sep 2022 00:33:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b="Rp0Ft/1F"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229828AbiIMGkb (ORCPT + 99 others); Tue, 13 Sep 2022 02:40:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbiIMGk3 (ORCPT ); Tue, 13 Sep 2022 02:40:29 -0400 Received: from mail-m975.mail.163.com (mail-m975.mail.163.com [123.126.97.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 89E0650067; Mon, 12 Sep 2022 23:40:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=sFjDE 3FMbVcbIWhkgqbv+dg2JpKyTv79I9Bu7jtu/kQ=; b=Rp0Ft/1FSZ1pRfFIDfv44 3S4OKNqnmoMDnDG+SDIVV3wc5X6uqVyLIYoOYVBKIoSZM6BPgKcLwuYI4ooZoZaN 8YQIhzPCaqD9I+9Sxr54R0e6o0KfSe5CT7qb5ZR0Q4WBjdl+GQL8CT4m3gkYXRWb TxUuzDw5JJuzBlfN0fatcw= Received: from localhost.localdomain (unknown [36.112.3.164]) by smtp5 (Coremail) with SMTP id HdxpCgCHGDKuJSBjsS_pcA--.50336S4; Tue, 13 Sep 2022 14:39:56 +0800 (CST) From: Jianglei Nie To: irusskikh@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jianglei Nie Subject: [PATCH] net: atlantic: fix potential memory leak in aq_ndev_close() Date: Tue, 13 Sep 2022 14:39:41 +0800 Message-Id: <20220913063941.83611-1-niejianglei2021@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: HdxpCgCHGDKuJSBjsS_pcA--.50336S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrtFWrtrWfCF4xWF4kAr1rCrg_yoWDJFX_Cr 4rX3Z7tw4UKr4jvw4Utr43A3s2vrs2q397Za47trW3K3WkGw47JryqvF43J3yUu34IvFn8 GFnrXF42v34jkjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRMjgxUUUUUU== X-Originating-IP: [36.112.3.164] X-CM-SenderInfo: xqlhyxxdqjzvrlsqjii6rwjhhfrp/1tbiQxl7jFc7bXJxXwAAsw X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If aq_nic_stop() fails, aq_ndev_close() returns err without calling aq_nic_deinit() to release the relevant memory and resource, which will lead to a memory leak. We can fix it by deleting the if condition judgment and goto statement to call aq_nic_deinit() directly after aq_nic_stop() to fix the memory leak. Signed-off-by: Jianglei Nie --- drivers/net/ethernet/aquantia/atlantic/aq_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_main.c b/drivers/net/ethernet/aquantia/atlantic/aq_main.c index 88595863d8bc..362f8077ff97 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_main.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_main.c @@ -94,8 +94,6 @@ static int aq_ndev_close(struct net_device *ndev) int err = 0; err = aq_nic_stop(aq_nic); - if (err < 0) - goto err_exit; aq_nic_deinit(aq_nic, true); err_exit: -- 2.25.1