Received: by 2002:ac0:c50a:0:0:0:0:0 with SMTP id y10csp999887imi; Fri, 1 Jul 2022 00:18:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1suM1pSA6Dn3vRMtFsDOMQV0baTl00urZeLlOjHom9OMHXrU8SyUNfGC0WqnzcdXvLm1Cic X-Received: by 2002:a17:906:74c7:b0:722:e657:4220 with SMTP id z7-20020a17090674c700b00722e6574220mr12703293ejl.589.1656659916305; Fri, 01 Jul 2022 00:18:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656659916; cv=none; d=google.com; s=arc-20160816; b=UPUpbj4zihYzHet6hn+5bhkzuA/Q9iYMX7n1fkH1Lnk2zBqOuDoDFGx3fyPHXAburK putrFyGQ77v1lJs+f9jylz/puPT2gh8S7BpvrRrNfcP53lhbppWffnAdFMv9G6kc3F1O JygvbdLtwPMY5aG6JIVHc35uBv+/ig68JfF/CUbMs7As4msqYy70AZpVXM+EdHSt17hu hqFc273E/UYhwyZP/660cTDftaPdVLMtwha00X7tuUv7U2RmohBUmsgoU3wki0TkNCBh zvQlQjQ5Tl71aIZYf9hcJctk9U5UjSuOAWehzap7VP2tDhAdOPuZVcC5lEEjnkk9dIKL wHRw== 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=RtOkwUCRvJPwXAmoRRVYheKTHhq6zc5VRxqZFuoYImA=; b=flV1XJEqd1GUk+MyGQ4B3Dgq260VZthqsS9r1oL5YEhHaXwOXg/KMdz6uPlx1FN9jX qMFv6EiUwv9M4q0v5u9Lhfk5oJLV1qreOMNIR9A8p+vVD+SRG0z1g+aXp2D24YF/fwWN QExXliPCcMkJ5vVKF2yLxtK/+PUx5AHMIs4o7P+MnrT0b9rBrEAnSdv9k6W8qyoJVpcb 2RrCDIS2uD8k6NufPw3UaGH5iEboTa9EGD74FdXp/MWcQibKac+LUwJRcbBo34xnapkW HbKahdn8s5ve/rlfJ8ZWBDZ4dYWSofLm6HrG3bYlGnembpGNDBrfLDZA5KZ8F2D3Nwse yIUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=YFGCIIHC; 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 nd38-20020a17090762a600b006ff8cd702e8si527494ejc.29.2022.07.01.00.18.10; Fri, 01 Jul 2022 00:18:36 -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=YFGCIIHC; 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 S234651AbiGAGxp (ORCPT + 99 others); Fri, 1 Jul 2022 02:53:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231426AbiGAGxo (ORCPT ); Fri, 1 Jul 2022 02:53:44 -0400 Received: from mail-m972.mail.163.com (mail-m972.mail.163.com [123.126.97.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 86D66599FE; Thu, 30 Jun 2022 23:53:42 -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=RtOkw UCRvJPwXAmoRRVYheKTHhq6zc5VRxqZFuoYImA=; b=YFGCIIHC6Ygk97U/8aJDR ZFdHmM71yhMwD0TyUFZJTZSPJviLHQCF5goQcFpNl7RPA43+7r5Ro7IKidKo7ac9 D16FoDOwET8n4eT8U65lZlGFaSB/1NQ6WG9hKMcOY9zMWbTs11zD11ZuOxkADQdu lSRQ6bUeVm8iabEdZK3Sns= Received: from localhost.localdomain (unknown [123.112.69.106]) by smtp2 (Coremail) with SMTP id GtxpCgDXq+fJmb5iT3T1Mg--.20281S4; Fri, 01 Jul 2022 14:53:13 +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: Fri, 1 Jul 2022 14:52:53 +0800 Message-Id: <20220701065253.2183789-1-niejianglei2021@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: GtxpCgDXq+fJmb5iT3T1Mg--.20281S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrtFWrtrWfCF4xWF4kAr1rCrg_yoWDXrc_Cr 4Fq3Wftw4UKr4jvw4Dtr43A3sFvrs2q397Z3W7trWfK3WkKw47GryqvF4fJ3yUuw1IvFnx WFnrWFW2v340yjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_knY3UUUUU== X-Originating-IP: [123.112.69.106] X-CM-SenderInfo: xqlhyxxdqjzvrlsqjii6rwjhhfrp/1tbiPgUxjFxBtDVsZgABsR 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 | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_main.c b/drivers/net/ethernet/aquantia/atlantic/aq_main.c index 88595863d8bc..8a0af371e7dc 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_main.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_main.c @@ -94,11 +94,8 @@ 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: return err; } -- 2.25.1