Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4391226rdb; Mon, 11 Dec 2023 19:15:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUbsZtbVbAhKBrP4L6PjweQ+dN1aDjrmFWHm+XrIjUicGXlRZK7intII5yis3PaE4LSIXc X-Received: by 2002:a0d:ee05:0:b0:5d7:1940:dd65 with SMTP id x5-20020a0dee05000000b005d71940dd65mr3955293ywe.59.1702350904988; Mon, 11 Dec 2023 19:15:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702350904; cv=none; d=google.com; s=arc-20160816; b=IDUc6wi4ZnpoSxgfjJAaHB8bHdiSdqPumW+4JEK3Hg+NowdI/PyrnmQJPiorg7lViV CJ6uZfonFtiBnwcteRcln8Kn6mvDy9YVAqzBgf/+jQHm8MaNHBoEcF8UagLQYos8+3jh B0KRyptNtG1ZQeU9yKP2e2hv3k0PVb6dkhLag9K4nCMZX8xIPJ2yhzAQo79AHuliRprd icguomRTsnaHc660iLT8RAEwxGasEW8QdSt36QWzQ+dsK00QOTwe3d3r8/W7ArWt+BND Oljso9KpnE6CvWylpXcAsj1kojhj3KcmY8oXl29DIEK6K1/gIY5BW7KYRDq6ve61VYOv r0Ug== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=BrZmErYR29tq42aJ10/77JNxeUCsYFB5sElMKIoR5dc=; fh=oEB00UBP2gYlI2scUel/IH2MJsKLcIZzjtJE8pnjxxE=; b=m9XYX5N2KqVojXoQtpP2f8ZU9qnzaawIYDkYRD2CIemGcGmuSwUqxwyyAA1VaiSNRV 6Obf3dEhuM3x+4CL2nU4cqsMS3UinIxWusQ57Kk1xlrHq/4MV5o/djcGaIliomf/Nu7Y puUmgHF+phtFzABw8Mc6TyBKg20uuMMI+DFBFMPo3cQ7cDSsdDhVu9ghJ+LyXCIhfR/3 PK7JOrEoqGI9RcvzGkqfmaMm4oymoZjr0LmTRQIIVXfDhXRgBx8eoOas4ml/3Ng8hkOI 8qWjDKqdfj/C7U7+IDS5BH4Da72+JP6U9fwXw/eqhtRLQjidnwxaiZGetUSql+VmYZhn FIRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mGGI4j1K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id n2-20020a170902d2c200b001d0c3e70d3asi7110308plc.490.2023.12.11.19.15.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 19:15:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mGGI4j1K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D8ED9804E727; Mon, 11 Dec 2023 19:15:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345788AbjLLDOo (ORCPT + 99 others); Mon, 11 Dec 2023 22:14:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbjLLDOn (ORCPT ); Mon, 11 Dec 2023 22:14:43 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41267BA for ; Mon, 11 Dec 2023 19:14:50 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5684CC433C8; Tue, 12 Dec 2023 03:14:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702350889; bh=STg08q9IfAR0tNeI5v/tHfkB1R036nNdGe+t8ciundo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mGGI4j1KtWPXG5XGxthX++rr+bHOo5M5KapVd0sqkY+j1yldnfhLfC4aaACy1aWI2 ud0jdHjYUeKrctIRwt2fGHY9fRzK5bwfSYJ1KmR9YncddGbA++5VzbVI2pvgtJqbAh yYw+fBJxNluQopj+4tE4bB2UFGzhvbfup8GwOhnz9qe/gfII8lLoJobSRIyKsnzAif 49FFgsq4s72rZtT3vv0H+HOlgZH0Y7Sbmx9caRGP3B5Px3bbJEqSUbHf0swUY/tPJq kMmhT82qgp3Bm5cewmGktHqixr54eFUb27YsauJjURm38BnJUVlEUlaAqoWBTvuQSj JqU+tbzbPG3/Q== Date: Mon, 11 Dec 2023 19:14:47 -0800 From: Jakub Kicinski To: Zhipeng Lu Cc: Chris Snook , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Yuanjun Gong , Jie Yang , Jeff Garzik , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] [v2] ethernet: atheros: fix a memleak in atl1e_setup_ring_resources Message-ID: <20231211191447.0408689d@kernel.org> In-Reply-To: <20231208082316.3384650-1-alexious@zju.edu.cn> References: <20231208082316.3384650-1-alexious@zju.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 11 Dec 2023 19:15:04 -0800 (PST) On Fri, 8 Dec 2023 16:23:14 +0800 Zhipeng Lu wrote: > v2: Setting tx_ring->tx_buffer to NULL after free. Having closer look at this driver - it tries to free both on close and remove, so seems like we do indeed have to NULL-out the pointer, sigh. > diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c > index 5935be190b9e..1bffe77439ac 100644 > --- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c > +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c > @@ -866,6 +866,8 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter) > netdev_err(adapter->netdev, "offset(%d) > ring size(%d) !!\n", > offset, adapter->ring_size); > err = -1; > + kfree(tx_ring->tx_buffer); > + tx_ring->tx_buffer = NULL; > goto failed; Please add a new jump target, tho, and move the freeing there. There's a small chance someone will add more code to this function and it will need to copy / paste this unwind. -- pw-bot: cr