Received: by 2002:ac0:c50a:0:0:0:0:0 with SMTP id y10csp1351719imi; Fri, 1 Jul 2022 08:03:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vy86m0PJGmXvqEcRG/RlT7zAVDW9a2VEuv6vgJQJRHXGweu3tfwLyvU0mus/IBbAMif7m4 X-Received: by 2002:a05:6a00:a8b:b0:4cd:6030:4df3 with SMTP id b11-20020a056a000a8b00b004cd60304df3mr20457638pfl.40.1656687831663; Fri, 01 Jul 2022 08:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656687831; cv=none; d=google.com; s=arc-20160816; b=uHzfrVQ2gjCzkvcs9BIxfDpaWB2iaT/eCB0ohsux6SAHL8QbtO1vCfWlVOoJfilzKC pua6STlT/s9DxFNyCGV9IqjlAlopXadO6YpAqhcoU/x3NJmuOiFrQZdl2zZV/lhZFVuK H7RtfW3afDlQRyC446Urvnjod3dVeChCTOU3ZlkjKoa28wBpGyWy+NaZN18WLyBhsy07 cCu4zGFo2nimEfanjHnacJsqFRJE7t7G2F1BolYvwxgmQ8PaIzIsRVqAtZCQEi2OWqPX wgBK2uycDaJFSFQVOoi7myfVJQ54dqvVRx0LcfxLNxPSgEkIFwmyLWa9zIP595T5LqRA yhbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-filter; bh=66Ql3pAlEnCDWDBK1KpaLaZ5id556xQAtLfeDM/YJ94=; b=xanHeLu7jfBm66qe0AAGKyweMfTnqDkNOnbUam9jhxL8vrJjpDGlMxgbhfRQhncbrD FupQ2r4hlxk5JHkLqnx5hic37jnwfWnWCWcBNsMmoeEEU7keAfVUCF77pKrUpB9tzLzh vcHYSflwbKGonMZxU7DVr07NtBtsyDz5opWoy3Ndj2prp25qnHp3PrF7RXOX9yH0uIb3 aHPA0MtymFHSvWRahf9EFmDtncwgYb3zXim9LTyoWYwflNfTUDCeGrP7MTlwNbhcI7Sz lNZw05xcdlaGUs+cZtB8DNLgykoj/QzY/32b4+MW4kdV/Tt9ROnIdwQsogZFcdHZCI0b ApBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fr.zoreil.com header.s=v20220413 header.b=kIun5lHt; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 145-20020a630697000000b003fdb97d8757si31571527pgg.378.2022.07.01.08.03.33; Fri, 01 Jul 2022 08:03:51 -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=@fr.zoreil.com header.s=v20220413 header.b=kIun5lHt; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231405AbiGAOiM (ORCPT + 99 others); Fri, 1 Jul 2022 10:38:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231237AbiGAOhz (ORCPT ); Fri, 1 Jul 2022 10:37:55 -0400 Received: from violet.fr.zoreil.com (violet.fr.zoreil.com [IPv6:2001:4b98:dc0:41:216:3eff:fe56:8398]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAB61396BD; Fri, 1 Jul 2022 07:34:10 -0700 (PDT) Received: from violet.fr.zoreil.com ([127.0.0.1]) by violet.fr.zoreil.com (8.17.1/8.17.1) with ESMTP id 261EXTCu876807; Fri, 1 Jul 2022 16:33:29 +0200 DKIM-Filter: OpenDKIM Filter v2.11.0 violet.fr.zoreil.com 261EXTCu876807 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fr.zoreil.com; s=v20220413; t=1656686009; bh=66Ql3pAlEnCDWDBK1KpaLaZ5id556xQAtLfeDM/YJ94=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kIun5lHtXquqsIs+UbvVm13eUHAzHVhXUPGck47CMbaE5risqntEzYY3HeJwMxvTj 7DGOFgvFCI5x3wSAL22s+JS3gl5ip/s8590PVe3OgiLpYl+8MlnJq95HcAv8cGkh4/ s7d+uBbJRmesAUkOCppcLmJru8KByK/iAiTjhdr4= Received: (from romieu@localhost) by violet.fr.zoreil.com (8.17.1/8.17.1/Submit) id 261EXS9v876806; Fri, 1 Jul 2022 16:33:28 +0200 Date: Fri, 1 Jul 2022 16:33:28 +0200 From: Francois Romieu To: Jianglei Nie Cc: irusskikh@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: atlantic: fix potential memory leak in aq_ndev_close() Message-ID: References: <20220701065253.2183789-1-niejianglei2021@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220701065253.2183789-1-niejianglei2021@163.com> X-Organisation: Land of Sunshine Inc. X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,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 Jianglei Nie : > 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 Either (1) the hardware is stopped and the relevance of error returning aq_nic_stop is dubious at best or (2) the hardware is not stopped and it may not be safe to remove its kernel allocated resources behind its back. There is a problem but this patch is imho targeting the symptom. A knowledgeable answer to (1), (2) could also help to avoid the dev_{close/open} danse in drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c. -- Ueimor