Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp978655lqp; Thu, 23 May 2024 06:02:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVDoHBPTvdUgbsRtuzsPxEH3m7pUCvwSlZZFMiS+IIeNc/Cebk7Z21q1Nvw0XUZ7RDTmQSf2XVrSQeZemB1L3kCI/aV792Y9tzTvug6JA== X-Google-Smtp-Source: AGHT+IE9FlkYzltlh0cg57MqhsEKkaKrWZf4bfhaYbXPnFTuv3M0cOFbI98Qm0BkDdWLFEfIIgDl X-Received: by 2002:a05:622a:1347:b0:43a:89c1:6b76 with SMTP id d75a77b69052e-43f9e1d781dmr50433341cf.65.1716469337357; Thu, 23 May 2024 06:02:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716469337; cv=pass; d=google.com; s=arc-20160816; b=eNcrEw3Sm2EnAUOgjouWL8OW91Ht4HJiI74gvpbgFAWjl21ik2KTd+3+Kg/DhI1D6K vB1teeKA9PZfJ6nRDuT4Jkjy0c9Za9rXzKYlpJb1XxMHIprOuJYZGyNO2CgosS2QveSe sEzA7rDhftpCrOPetJYsLrSD9mXc+7i9v4DLx65jP7+GV15Xel+lvMp+rl/Z1TXcgPz5 4AyTC4mpApSWa/OFk3JTreSyKe3QMl3QWH4tk9+IQtvQIeblcLB8VkGLmDsm3kc+YnFI TWMkASnZxF8vpDjzgxJN/heASBz4ZE3JnDliXd0NYoUlGfNNY1uviADxmLbkyzk06sp+ dr2w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=UTBLLIVYfkg4QE6/jefBW6vdILy6/+yw6lYO8WeGjC0=; fh=CeX6eYQcNW4G4BiJ4UGwY7u5xXVgjLX8HT+k2/JIbpg=; b=qlELQlx5vAUJ2ucUiFtqJ8vCOXrROyjxR2D6JXCTmRz341ZzGjI9k/mIwKEZZvHrhA MXz/4zUSN6qlgUikyqKrfGxmBFbqP3gX/8FFzPJfZ4mur74I7Y2blkBlngWVuhrXvQx8 VWUqQ2+99KHjA+tcnUmb6aHPg2By4g56uLf7B48RHfyR3ashFxn/wCdvgHkNm9d6TTad v3RMFH0qaFlpRS8l8KmEbJ/kNi5ZlNJHmyu3RfErqnKmfb7tOCBazTqh+vUZ7Q076/HU 6EW+TdJfIkTCkelzMpjUg8OofZiIhNY2v9ggocP012ZuqlnBawAhdlXQB+zI5s0gwbyj V9iQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=QbP0Y189; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-187534-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187534-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43df69dd153si324101051cf.755.2024.05.23.06.02.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 06:02:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187534-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=QbP0Y189; arc=pass (i=1 spf=pass spfdomain=lunn.ch dkim=pass dkdomain=lunn.ch dmarc=pass fromdomain=lunn.ch); spf=pass (google.com: domain of linux-kernel+bounces-187534-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187534-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1664C1C21D3F for ; Thu, 23 May 2024 13:02:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3003914A4F4; Thu, 23 May 2024 13:02:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="QbP0Y189" Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26F6413B7BC; Thu, 23 May 2024 13:02:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716469328; cv=none; b=XIIOugmZyiVVEKqNuWWpdyB05D5b7NWF5kh0Ee8poKvgbzgzt1CXo54lbV2tU6ycQSGczB2Rj80ncbO180qBrkhzQKfegExllsa8kCo0vTaMBBGMaqwJiCX5TMLBnCS/rSUfp+Bc965URKH5Nwok5Q6ushOE7i2ErvvQ6Lty6vw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716469328; c=relaxed/simple; bh=xyTHuhkTsGkxCewXIYtJbN5u25VhvmjpyGsoQHV0W9k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=utA1UPnvQMkjVEvg0rRPtM/UpTz4P2nzCrZCAuQGjaCWu3pBd27OeYqkwJI0MWy5PkgmDzt1ljR6hJB5nPjq0HE+yv/vQLSR73kQpCjTAnavSzrcvh4w/ntai4dQxLT/CM4FJd2ShUnbg7Micrboy6bbmgUH+wdqvxdWrLyo05E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=QbP0Y189; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=UTBLLIVYfkg4QE6/jefBW6vdILy6/+yw6lYO8WeGjC0=; b=QbP0Y189CLpNctPQTudUmRk1Hp CnoFA3HBpff5S8O7cAr0W5DFAGb9qCv4zmMenPG2OPe0x4VxqZCTxIY4K7LCo/SjXD5tDAL9HwW6G +pkUcOHCK5khO6K64DMxwScxrxlM3e0S+CnEouAx/DgecW8LdkiTLRR2cv8BXLo5CjZk=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1sA84x-00FtRZ-90; Thu, 23 May 2024 15:01:55 +0200 Date: Thu, 23 May 2024 15:01:55 +0200 From: Andrew Lunn To: Xiaolei Wang Cc: wei.fang@nxp.com, shenwei.wang@nxp.com, xiaoning.wang@nxp.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, imx@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [v2 PATCH] net: fec: free fec queue when fec_probe() fails or fec_drv_remove() Message-ID: References: <20240523062920.2472432-1-xiaolei.wang@windriver.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240523062920.2472432-1-xiaolei.wang@windriver.com> On Thu, May 23, 2024 at 02:29:20PM +0800, Xiaolei Wang wrote: > commit 59d0f7465644 ("net: fec: init multi queue date structure") > allocates multiple queues, which should be cleaned up when fec_probe() > fails or fec_drv_remove(), otherwise a memory leak will occur. > > unreferenced object 0xffffff8010350000 (size 8192): > comm "kworker/u8:3", pid 39, jiffies 4294893562 > hex dump (first 32 bytes): > 02 00 00 00 00 00 00 00 00 50 06 8a c0 ff ff ff .........P...... > e0 6f 06 8a c0 ff ff ff 00 50 06 8a c0 ff ff ff .o.......P...... > backtrace (crc f1b8b79f): > [<0000000057d2c6ae>] kmemleak_alloc+0x34/0x40 > [<000000003c413e60>] kmalloc_trace+0x2f8/0x460 > [<00000000663f64e6>] fec_probe+0x1364/0x3a04 > [<0000000024d7e427>] platform_probe+0xc4/0x198 > [<00000000293aa124>] really_probe+0x17c/0x4f0 > [<00000000dfd1e0f3>] __driver_probe_device+0x158/0x2c4 > > Fixes: 59d0f7465644 ("net: fec: init multi queue date structure") > Signed-off-by: Xiaolei Wang Please read what i suggested. It is good to have code which is symmetric. probe() and remove() should be opposites of each other. probe() calls fec_enet_init(). So it would be good to have remove() call fec_enet_deinit() which does the opposite. We then have symmetry. Is there anything else in fec_enet_init() which needs undoing? A rule of thumb: If you find a bug, look around, there might be others nearby. Maybe leaking the queues is not the only problem? Andrew