From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Ira Weiny <ira.weiny@intel.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
Dave Jiang <dave.jiang@intel.com>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
<linux-cxl@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] cxl/pmu: Ensure put_device on pmu devices
Date: Wed, 18 Oct 2023 11:50:38 +0100 [thread overview]
Message-ID: <20231018115038.0000433d@Huawei.com> (raw)
In-Reply-To: <20231016-pmu-unregister-fix-v1-1-1e2eb2fa3c69@intel.com>
On Mon, 16 Oct 2023 16:25:05 -0700
Ira Weiny <ira.weiny@intel.com> wrote:
> The following kmemleaks were detected when removing the cxl module
> stack:
>
> unreferenced object 0xffff88822616b800 (size 1024):
> ...
> backtrace:
> [<00000000bedc6f83>] kmalloc_trace+0x26/0x90
> [<00000000448d1afc>] devm_cxl_pmu_add+0x3a/0x110 [cxl_core]
> [<00000000ca3bfe16>] 0xffffffffa105213b
> [<00000000ba7f78dc>] local_pci_probe+0x41/0x90
> [<000000005bb027ac>] pci_device_probe+0xb0/0x1c0
> ...
> unreferenced object 0xffff8882260abcc0 (size 16):
> ...
> hex dump (first 16 bytes):
> 70 6d 75 5f 6d 65 6d 30 2e 30 00 26 82 88 ff ff pmu_mem0.0.&....
> backtrace:
> ...
> [<00000000152b5e98>] dev_set_name+0x43/0x50
> [<00000000c228798b>] devm_cxl_pmu_add+0x102/0x110 [cxl_core]
> [<00000000ca3bfe16>] 0xffffffffa105213b
> [<00000000ba7f78dc>] local_pci_probe+0x41/0x90
> [<000000005bb027ac>] pci_device_probe+0xb0/0x1c0
> ...
> unreferenced object 0xffff8882272af200 (size 256):
> ...
> backtrace:
> [<00000000bedc6f83>] kmalloc_trace+0x26/0x90
> [<00000000a14d1813>] device_add+0x4ea/0x890
> [<00000000a3f07b47>] devm_cxl_pmu_add+0xbe/0x110 [cxl_core]
> [<00000000ca3bfe16>] 0xffffffffa105213b
> [<00000000ba7f78dc>] local_pci_probe+0x41/0x90
> [<000000005bb027ac>] pci_device_probe+0xb0/0x1c0
> ...
>
> devm_cxl_pmu_add() correctly registers a device remove function but it
> only calls device_del() which is only part of device unregistration.
>
> Properly call device_unregister() to free up the memory associated with
> the device.
>
> Fixes: 1ad3f701c399 ("cxl/pci: Find and register CXL PMU devices")
> Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Oops.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> drivers/cxl/core/pmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cxl/core/pmu.c b/drivers/cxl/core/pmu.c
> index 7684c843e5a5..5d8e06b0ba6e 100644
> --- a/drivers/cxl/core/pmu.c
> +++ b/drivers/cxl/core/pmu.c
> @@ -23,7 +23,7 @@ const struct device_type cxl_pmu_type = {
>
> static void remove_dev(void *dev)
> {
> - device_del(dev);
> + device_unregister(dev);
> }
>
> int devm_cxl_pmu_add(struct device *parent, struct cxl_pmu_regs *regs,
>
> ---
> base-commit: 58720809f52779dc0f08e53e54b014209d13eebb
> change-id: 20231016-pmu-unregister-fix-345480926a58
>
> Best regards,
prev parent reply other threads:[~2023-10-18 10:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 23:25 [PATCH] cxl/pmu: Ensure put_device on pmu devices Ira Weiny
2023-10-16 23:43 ` Dave Jiang
2023-10-17 15:35 ` Ira Weiny
2023-10-17 16:21 ` Dave Jiang
2023-10-18 10:50 ` Jonathan Cameron [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231018115038.0000433d@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox