From patchwork Mon Apr 19 11:25:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wong Vee Khee X-Patchwork-Id: 12211535 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA149C433ED for ; Mon, 19 Apr 2021 11:22:43 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6876661157 for ; Mon, 19 Apr 2021 11:22:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6876661157 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=+Crca7fpIfan9256Vffx1VsItvsqqfr4x5VI/Y9A0G8=; b=a4Hn9z8iEnT4q7cGj8v1ww5pHE IP/GZ3cXpt2Gj3yFWmHkKD89uXxpSK44/ysYiEBk9i2rsznP2bM4WLK0kNVysUUJ7H5Ciy5F7ggau 6d1hGdU7vViBaaJvN+EyfgrEC3zjofsA2DTozDBXQ964HqjVl6ZSB+H0PhebOGIx9QIqW61dbdIn3 KXSC1jhBTYeBnYZP75il/Mvz94mDpFN6YgDjHEEjlBl6GAGRFljJYLiLnzdpE+sd/es1+8wMwDRb+ rAr5sb+WlYRAI7OQ2PDdhOTwWp34PvrK8VUWWc+AcO+4qp454Xq3LZP/hoWXVMfpaFIWakwasoV+H fuS0ZI6g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYRxj-009kmR-6k; Mon, 19 Apr 2021 11:21:07 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYRxg-009kmB-8w for linux-arm-kernel@desiato.infradead.org; Mon, 19 Apr 2021 11:21:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=8du0Gu/law6REyz/04N6NtIFEUxbIcJrrGMIYdUtifs=; b=cEDUn/EuSLji1RQ2JbiT6vv4Sv jUgVq25uvbobuPXfSrXEZqhDdmNpR18PFYtz6Bx/Gai5PF197C76CbJdvB11CLYXwoTQJ8NEExclS M0Q5vUhSbLdUbxPvb01AhE2bqhwNc/ehplKp4Ojvx2yCbnbxUvo33yMIX0bbxtkWWWMiK3idMcYK3 dftLItjivhUc8JvXQAXWOTTPYvOWHb7AAjRlXrhztG/2L0EWjQiyXU8WpZEwba2mrrvaQi2y0MUQu RK3h2RJHreL7vDT/rLx8n/sI3coji843q8r0/RONw95YsBq5egCypOZzmqt19V3z90JrXPl13Nieh G0ZpBUiQ==; Received: from mga17.intel.com ([192.55.52.151]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYRxa-00BIop-4B for linux-arm-kernel@lists.infradead.org; Mon, 19 Apr 2021 11:21:02 +0000 IronPort-SDR: sLpNRixYf/8nWy21CfbyF9eyJCw7fXJWDCywuGHOeieajTf9Pha042ZVDL3SMXMrHUD0TDywun lNJ1MWFlYBPQ== X-IronPort-AV: E=McAfee;i="6200,9189,9958"; a="175415247" X-IronPort-AV: E=Sophos;i="5.82,234,1613462400"; d="scan'208";a="175415247" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2021 04:20:56 -0700 IronPort-SDR: gG9C6LbgTpQvO1pgi3EUWUtteiHAWMr3es6AOL9cOIY9BL44ntzJSGacgAPQMcVOriHIa6Wfu3 F5yC971w9myg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,234,1613462400"; d="scan'208";a="390630159" Received: from linux.intel.com ([10.54.29.200]) by fmsmga007.fm.intel.com with ESMTP; 19 Apr 2021 04:20:55 -0700 Received: from glass.png.intel.com (glass.png.intel.com [10.158.65.59]) by linux.intel.com (Postfix) with ESMTP id 669915808CA; Mon, 19 Apr 2021 04:20:53 -0700 (PDT) From: Wong Vee Khee To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S . Miller" , Jakub Kicinski , Maxime Coquelin Cc: Ong Boon Leong , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/1] net: stmmac: fix memory leak during driver probe Date: Mon, 19 Apr 2021 19:25:30 +0800 Message-Id: <20210419112530.20395-1-vee.khee.wong@linux.intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210419_042058_195644_C913507F X-CRM114-Status: UNSURE ( 8.04 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On driver probe, kmemleak reported the following memory leak which was due to allocated bitmap that was not being freed in stmmac_dvr_probe(). unreferenced object 0xffff9276014b13c0 (size 8): comm "systemd-udevd", pid 2143, jiffies 4294681112 (age 116.720s) hex dump (first 8 bytes): 00 00 00 00 00 00 00 00 ........ backtrace: [<00000000c51e34b2>] stmmac_dvr_probe+0x1c0/0x440 [stmmac] [<00000000b530eb41>] intel_eth_pci_probe.cold+0x2b/0x14e [dwmac_intel] [<00000000b10f8929>] pci_device_probe+0xd2/0x150 [<00000000fb254c74>] really_probe+0xf8/0x410 [<0000000034128a59>] driver_probe_device+0x5d/0x150 [<00000000016104d5>] device_driver_attach+0x53/0x60 [<00000000cb18cd07>] __driver_attach+0x96/0x140 [<00000000da9ffd5c>] bus_for_each_dev+0x7a/0xc0 [<00000000af061a88>] bus_add_driver+0x184/0x1f0 [<000000008be5c1c5>] driver_register+0x6c/0xc0 [<0000000052b18a9e>] do_one_initcall+0x4d/0x210 [<00000000154d4f07>] do_init_module+0x5c/0x230 [<000000009b648d09>] load_module+0x2a5a/0x2d40 [<000000000d86b76d>] __do_sys_finit_module+0xb5/0x120 [<000000002b0cef95>] do_syscall_64+0x33/0x40 [<0000000067b45bbb>] entry_SYSCALL_64_after_hwframe+0x44/0xa9 Fixes: bba2556efad6 ("net: stmmac: Enable RX via AF_XDP zero-copy") Cc: Ong Boon Leong Signed-off-by: Wong Vee Khee --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 9f396648d76f..d1ca07c846e6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7035,6 +7035,7 @@ int stmmac_dvr_probe(struct device *device, error_hw_init: destroy_workqueue(priv->wq); stmmac_bus_clks_config(priv, false); + bitmap_free(priv->af_xdp_zc_qps); return ret; } @@ -7077,6 +7078,7 @@ int stmmac_dvr_remove(struct device *dev) stmmac_mdio_unregister(ndev); destroy_workqueue(priv->wq); mutex_destroy(&priv->lock); + bitmap_free(priv->af_xdp_zc_qps); return 0; }