Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1985366pxx; Sat, 31 Oct 2020 04:53:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTYRQ1zuvIB8X33sYN+4GT608eIm1T2Zx3VXzbsXGxnnTx+E1iKw3DGo8mdzEEkxn2hrbg X-Received: by 2002:a17:906:3a02:: with SMTP id z2mr6704553eje.452.1604145189312; Sat, 31 Oct 2020 04:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604145189; cv=none; d=google.com; s=arc-20160816; b=BC6wfYI5vvGcO/DvZ8L5ChxZgNTiosBXNfng0jeJnmHBka1ueTtHZkjJvoYQfQ+y/W mxcQlbb9Ss2ZN991qtggMEyppcGOR0Ufsa2hFpmhOod+G9oUG1+ytkvpRs3rTWsd3dQm WLxRpnhHg0ju0mvC5MaApwoU7YhteJzvSMlpRpDIASRfNTKghlHOqDjerhE4U3HtUlLS Dz9+2JUtXbnDJufRS+zhqC0mjbvHtJGITnkYWPD/9VJdEd1e6X1rR0Vi/ltBeSi6U2yJ uvdZ1TNMaQLJ6/NaAjXq/nKB2GymicJz8iHaWCV3rOECS90rdBYOxd66uJkOtF6rZRu8 /OEg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SLnV7rllOQjvWeu5tB/50i1OeNAS6l2d9kYjnjR5rec=; b=fiRwziFOL24T2dihrzH1ELGRHYS6JAijbLFFmPaJCGMm2DCzHBG0q33CIlr4ME1qgi 60tNuSGa/VpwAaRUy8yQrp5cG8V/Z5WI3qFZHcgdnaT1ZVKX5Pqyxc1YGjeH4KIQk+NF PnJDZL1rAwTSGTz9s12K9NWTIuEcmfpu/yybI2PBFu8nnrB1SGCfYwzHCb8t6IbV+hFO lvL09Vgfyd/Tiaaon1rfVYQtnQMYEMnwD0axwun6jnU5JASJ7qhR+dXaqIuoFc/bW3mK 63+ZHcmPblbrJyO7txUcHS4iQPAo5S/mSIzaZb/Cqr+eW5pWgtJUmUIfK9x1Y7k9gIXn H7Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="hw1UV/9n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cn1si6499068edb.408.2020.10.31.04.52.47; Sat, 31 Oct 2020 04:53:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="hw1UV/9n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727652AbgJaLuN (ORCPT + 99 others); Sat, 31 Oct 2020 07:50:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:40674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbgJaLlf (ORCPT ); Sat, 31 Oct 2020 07:41:35 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4652320719; Sat, 31 Oct 2020 11:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604144494; bh=71/fyqCFGCStXvo4eThWyQuIuR+H/ksjOPKGbkCyXF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hw1UV/9nHiYYCuaSI70Dr0ARDz2m7g+YiWuIRp3gDklQgbwiN0C8N0tD5b06L6YrQ uKTGFfa5t2IUO5jy/uJHtQS5YR2OHPdMWFCbYvyWn05QEbwPPKL3cg3SRsx3KApwk3 qpup4BReK41qKQjNDLKWpmuOFxfz9l0Jf7TB+X+8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ido Schimmel , Vadim Pasternak , Oleksandr Shamray , Jakub Kicinski Subject: [PATCH 5.8 39/70] mlxsw: core: Fix memory leak on module removal Date: Sat, 31 Oct 2020 12:36:11 +0100 Message-Id: <20201031113501.370477307@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201031113459.481803250@linuxfoundation.org> References: <20201031113459.481803250@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ido Schimmel [ Upstream commit adc80b6cfedff6dad8b93d46a5ea2775fd5af9ec ] Free the devlink instance during the teardown sequence in the non-reload case to avoid the following memory leak. unreferenced object 0xffff888232895000 (size 2048): comm "modprobe", pid 1073, jiffies 4295568857 (age 164.871s) hex dump (first 32 bytes): 00 01 00 00 00 00 ad de 22 01 00 00 00 00 ad de ........"....... 10 50 89 32 82 88 ff ff 10 50 89 32 82 88 ff ff .P.2.....P.2.... backtrace: [<00000000c704e9a6>] __kmalloc+0x13a/0x2a0 [<00000000ee30129d>] devlink_alloc+0xff/0x760 [<0000000092ab3e5d>] 0xffffffffa042e5b0 [<000000004f3f8a31>] 0xffffffffa042f6ad [<0000000092800b4b>] 0xffffffffa0491df3 [<00000000c4843903>] local_pci_probe+0xcb/0x170 [<000000006993ded7>] pci_device_probe+0x2c2/0x4e0 [<00000000a8e0de75>] really_probe+0x2c5/0xf90 [<00000000d42ba75d>] driver_probe_device+0x1eb/0x340 [<00000000bcc95e05>] device_driver_attach+0x294/0x300 [<000000000e2bc177>] __driver_attach+0x167/0x2f0 [<000000007d44cd6e>] bus_for_each_dev+0x148/0x1f0 [<000000003cd5a91e>] driver_attach+0x45/0x60 [<000000000041ce51>] bus_add_driver+0x3b8/0x720 [<00000000f5215476>] driver_register+0x230/0x4e0 [<00000000d79356f5>] __pci_register_driver+0x190/0x200 Fixes: a22712a96291 ("mlxsw: core: Fix devlink unregister flow") Signed-off-by: Ido Schimmel Reported-by: Vadim Pasternak Tested-by: Oleksandr Shamray Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlxsw/core.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/net/ethernet/mellanox/mlxsw/core.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c @@ -1483,6 +1483,8 @@ void mlxsw_core_bus_device_unregister(st if (!reload) devlink_resources_unregister(devlink, NULL); mlxsw_core->bus->fini(mlxsw_core->bus_priv); + if (!reload) + devlink_free(devlink); return;