From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2734EC433EF for ; Fri, 1 Jul 2022 14:38:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233482AbiGAOiN (ORCPT ); Fri, 1 Jul 2022 10:38:13 -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. 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