Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp583681rwb; Wed, 7 Dec 2022 02:23:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf5B17qmrI4nzByOnxjfWYRvztHoxuImQtC8hfgoYQ3SlmOcv7ToGZOJU9savUNhkLnlXC4W X-Received: by 2002:aa7:96e5:0:b0:576:fee5:6927 with SMTP id i5-20020aa796e5000000b00576fee56927mr12910476pfq.70.1670408631457; Wed, 07 Dec 2022 02:23:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670408631; cv=none; d=google.com; s=arc-20160816; b=pcXZyT8/Q3a1+WqzfevOyZZtNKR0ezHJn7eakj7ugqiczqSRlx/17pw3/mhVbUk/ov AbnYO24gQGVX7dGq+CS0ounsBV0IsSyBKWcnBRSYFK+CEPSEzyinwaTN1W+u4uIGLcVZ D9Htp/G3VfdJ3eNeT/bhfRYiHZEabelzjs1VUCa4cZ5xWoookd6g4RgBvdDZ2na4P65C 7acGo/XENIFBaRadXEFa/MGpNg3kHU2N1Xnc7wgRTSKzosQ8n3PYWvHWyJt5VyFun9ol 2Vlj7DA9Xphn447dciGJLy6OlYl5LZAZGHVZPcsram1olOim3JTUxBpvKtNFchH/HZ2R zbbw== 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; bh=fGDIPPvSDwg3moSV49qVLEswsDme7pUwr+1Y0/ymkx8=; b=ju2wce4aHEmSgLP1M1ZyaZGeI3pULWbeiiJmWyhXxkYfpn7XqwFc0EuW0uBgzK6lC5 ujqKmeWyqboEWIXqMaFnzbgnS3V8tQTUXiILItn6oAenKYIZrWG6bhoQyYXcT1bC3o8n 1ApmVSrSQF+if6jYlTPauty5mvsCOvcrxaSb0Ib60AnbQ/Zpm7r9CjQPazmZDdhdD+r3 +mfmhN64ITXDyNSUZKBX7kU/z50Zz6Jca6KsaoDAzY73ozrkXTDPnD+moikP66+Q25lT Ct5sBknahRcp/nu6lnWaVMgtGYCHm81SXZDY/80A2YueY2P5UY9YfLBVOygFzwj9a8A1 Zoxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LdCl54ES; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c19-20020a056a000ad300b0056e770672c1si22061618pfl.305.2022.12.07.02.23.41; Wed, 07 Dec 2022 02:23:51 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=LdCl54ES; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230015AbiLGJNN (ORCPT + 76 others); Wed, 7 Dec 2022 04:13:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230011AbiLGJMh (ORCPT ); Wed, 7 Dec 2022 04:12:37 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2D7211B; Wed, 7 Dec 2022 01:12:32 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1C39EB80189; Wed, 7 Dec 2022 09:12:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 582E7C433D6; Wed, 7 Dec 2022 09:12:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670404349; bh=fQa6B7E0Sk8yD7Z1ApAog2OUJ3gEMBIbSKp3KTXR5Co=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LdCl54ESA51k3chtydSBzfMUZGWmc+kMfLRk4eI7dpVYPq+4r36oiHVvfzqPTnmmv 4ftXtc98gIzTgMHHIF4Y4jtQG/ca7pciF1J39Gon2IrB2bYHwAWRm4PcjGRLW/j2xt H2mfj4QWT+tBge/2vsM2Hi77ptoGhfcUwx+jhsKaZosI58yehEJavBPMcsJq82pYnG Tl5102MRgBdTAGkcuBdCw68qE+lRDrcpCR6XhNdFAVsQ8tLMzIDCcXJxz69j0KfYpc 9D0uBrGCxHHSDXffT4+yTnqwIDtr6Wetw/1L2VWDB+NkSZkzL9bE6N54C5BaqCQ1++ NU4crXp14djwg== Date: Wed, 7 Dec 2022 11:12:25 +0200 From: Leon Romanovsky To: Zhang Changzhong Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net] net: stmmac: selftests: fix potential memleak in stmmac_test_arpoffload() Message-ID: References: <1670401920-7574-1-git-send-email-zhangchangzhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1670401920-7574-1-git-send-email-zhangchangzhong@huawei.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 On Wed, Dec 07, 2022 at 04:31:59PM +0800, Zhang Changzhong wrote: > The skb allocated by stmmac_test_get_arp_skb() hasn't been released in > some error handling case, which will lead to a memory leak. Fix this up > by adding kfree_skb() to release skb. > > Compile tested only. > > Fixes: 5e3fb0a6e2b3 ("net: stmmac: selftests: Implement the ARP Offload test") > Signed-off-by: Zhang Changzhong > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c > index 49af7e7..687f43c 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c > @@ -1654,12 +1654,16 @@ static int stmmac_test_arpoffload(struct stmmac_priv *priv) > } > > ret = stmmac_set_arp_offload(priv, priv->hw, true, ip_addr); > - if (ret) > + if (ret) { > + kfree_skb(skb); > goto cleanup; > + } > > ret = dev_set_promiscuity(priv->dev, 1); > - if (ret) > + if (ret) { > + kfree_skb(skb); > goto cleanup; > + } > > ret = dev_direct_xmit(skb, 0); > if (ret) You should release skb here too. So the better patch will be to write something like that: cleanup: stmmac_set_arp_offload(priv, priv->hw, false, 0x0); if (ret) kfree_skb(skb); Thanks > -- > 2.9.5 >