<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/cxl/core/pmu.c, branch v6.12</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>cxl/pmu: Ensure put_device on pmu devices</title>
<updated>2023-12-15T05:54:45+00:00</updated>
<author>
<name>Ira Weiny</name>
<email>ira.weiny@intel.com</email>
</author>
<published>2023-10-16T23:25:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ef3d5cf9c59cccb012aa6b93d99f4c6eb5d6648e'/>
<id>ef3d5cf9c59cccb012aa6b93d99f4c6eb5d6648e</id>
<content type='text'>
The following kmemleaks were detected when removing the cxl module
stack:

unreferenced object 0xffff88822616b800 (size 1024):
...
  backtrace:
    [&lt;00000000bedc6f83&gt;] kmalloc_trace+0x26/0x90
    [&lt;00000000448d1afc&gt;] devm_cxl_pmu_add+0x3a/0x110 [cxl_core]
    [&lt;00000000ca3bfe16&gt;] 0xffffffffa105213b
    [&lt;00000000ba7f78dc&gt;] local_pci_probe+0x41/0x90
    [&lt;000000005bb027ac&gt;] 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.&amp;....
  backtrace:
...
    [&lt;00000000152b5e98&gt;] dev_set_name+0x43/0x50
    [&lt;00000000c228798b&gt;] devm_cxl_pmu_add+0x102/0x110 [cxl_core]
    [&lt;00000000ca3bfe16&gt;] 0xffffffffa105213b
    [&lt;00000000ba7f78dc&gt;] local_pci_probe+0x41/0x90
    [&lt;000000005bb027ac&gt;] pci_device_probe+0xb0/0x1c0
...
unreferenced object 0xffff8882272af200 (size 256):
...
  backtrace:
    [&lt;00000000bedc6f83&gt;] kmalloc_trace+0x26/0x90
    [&lt;00000000a14d1813&gt;] device_add+0x4ea/0x890
    [&lt;00000000a3f07b47&gt;] devm_cxl_pmu_add+0xbe/0x110 [cxl_core]
    [&lt;00000000ca3bfe16&gt;] 0xffffffffa105213b
    [&lt;00000000ba7f78dc&gt;] local_pci_probe+0x41/0x90
    [&lt;000000005bb027ac&gt;] 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 &lt;Jonathan.Cameron@huawei.com&gt;
Signed-off-by: Ira Weiny &lt;ira.weiny@intel.com&gt;
Reviewed-by: Jonathan Cameron &lt;Jonathan.Cameron@huawei.com&gt;
Reviewed-by: Dave Jiang &lt;dave.jiang@intel.com&gt;
Link: https://lore.kernel.org/r/20231016-pmu-unregister-fix-v1-1-1e2eb2fa3c69@intel.com
Signed-off-by: Dan Williams &lt;dan.j.williams@intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The following kmemleaks were detected when removing the cxl module
stack:

unreferenced object 0xffff88822616b800 (size 1024):
...
  backtrace:
    [&lt;00000000bedc6f83&gt;] kmalloc_trace+0x26/0x90
    [&lt;00000000448d1afc&gt;] devm_cxl_pmu_add+0x3a/0x110 [cxl_core]
    [&lt;00000000ca3bfe16&gt;] 0xffffffffa105213b
    [&lt;00000000ba7f78dc&gt;] local_pci_probe+0x41/0x90
    [&lt;000000005bb027ac&gt;] 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.&amp;....
  backtrace:
...
    [&lt;00000000152b5e98&gt;] dev_set_name+0x43/0x50
    [&lt;00000000c228798b&gt;] devm_cxl_pmu_add+0x102/0x110 [cxl_core]
    [&lt;00000000ca3bfe16&gt;] 0xffffffffa105213b
    [&lt;00000000ba7f78dc&gt;] local_pci_probe+0x41/0x90
    [&lt;000000005bb027ac&gt;] pci_device_probe+0xb0/0x1c0
...
unreferenced object 0xffff8882272af200 (size 256):
...
  backtrace:
    [&lt;00000000bedc6f83&gt;] kmalloc_trace+0x26/0x90
    [&lt;00000000a14d1813&gt;] device_add+0x4ea/0x890
    [&lt;00000000a3f07b47&gt;] devm_cxl_pmu_add+0xbe/0x110 [cxl_core]
    [&lt;00000000ca3bfe16&gt;] 0xffffffffa105213b
    [&lt;00000000ba7f78dc&gt;] local_pci_probe+0x41/0x90
    [&lt;000000005bb027ac&gt;] 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 &lt;Jonathan.Cameron@huawei.com&gt;
Signed-off-by: Ira Weiny &lt;ira.weiny@intel.com&gt;
Reviewed-by: Jonathan Cameron &lt;Jonathan.Cameron@huawei.com&gt;
Reviewed-by: Dave Jiang &lt;dave.jiang@intel.com&gt;
Link: https://lore.kernel.org/r/20231016-pmu-unregister-fix-v1-1-1e2eb2fa3c69@intel.com
Signed-off-by: Dan Williams &lt;dan.j.williams@intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cxl/pci: Find and register CXL PMU devices</title>
<updated>2023-05-30T18:20:35+00:00</updated>
<author>
<name>Jonathan Cameron</name>
<email>Jonathan.Cameron@huawei.com</email>
</author>
<published>2023-05-26T09:58:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=1ad3f701c3999904d0c6cdea299df16c6cd9878d'/>
<id>1ad3f701c3999904d0c6cdea299df16c6cd9878d</id>
<content type='text'>
CXL PMU devices can be found from entries in the Register
Locator DVSEC.

Reviewed-by: Dan Williams &lt;dan.j.williams@intel.com&gt;
Reviewed-by: Dave Jiang &lt;dave.jiang@intel.com&gt;
Signed-off-by: Jonathan Cameron &lt;Jonathan.Cameron@huawei.com&gt;
Link: https://lore.kernel.org/r/20230526095824.16336-4-Jonathan.Cameron@huawei.com
Signed-off-by: Dan Williams &lt;dan.j.williams@intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
CXL PMU devices can be found from entries in the Register
Locator DVSEC.

Reviewed-by: Dan Williams &lt;dan.j.williams@intel.com&gt;
Reviewed-by: Dave Jiang &lt;dave.jiang@intel.com&gt;
Signed-off-by: Jonathan Cameron &lt;Jonathan.Cameron@huawei.com&gt;
Link: https://lore.kernel.org/r/20230526095824.16336-4-Jonathan.Cameron@huawei.com
Signed-off-by: Dan Williams &lt;dan.j.williams@intel.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
