LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] drivers/base: kmemleak ignore a known leak
@ 2018-11-29 15:12 Qian Cai
  2018-12-06 16:07 ` [RESEND PATCH] " Qian Cai
  0 siblings, 1 reply; 3+ messages in thread
From: Qian Cai @ 2018-11-29 15:12 UTC (permalink / raw)
  To: gregkh, rafael; +Cc: linux-kernel, Qian Cai

unreferenced object 0xffff808ec6dc5a80 (size 128):
  comm "swapper/0", pid 1, jiffies 4294938063 (age 2560.530s)
  hex dump (first 32 bytes):
    ff ff ff ff 00 00 00 00 6b 6b 6b 6b 6b 6b 6b 6b  ........kkkkkkkk
    6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
  backtrace:
    [<00000000476dcf8c>] kmem_cache_alloc_trace+0x430/0x500
    [<000000004f708d37>] platform_device_register_full+0xbc/0x1e8
    [<000000006c2a7ec7>] acpi_create_platform_device+0x370/0x450
    [<00000000ef135642>] acpi_default_enumeration+0x34/0x78
    [<000000003bd9a052>] acpi_bus_attach+0x2dc/0x3e0
    [<000000003cf4f7f2>] acpi_bus_attach+0x108/0x3e0
    [<000000003cf4f7f2>] acpi_bus_attach+0x108/0x3e0
    [<000000002968643e>] acpi_bus_scan+0xb0/0x110
    [<0000000010dd0bd7>] acpi_scan_init+0x1a8/0x410
    [<00000000965b3c5a>] acpi_init+0x408/0x49c
    [<00000000ed4b9fe2>] do_one_initcall+0x178/0x7f4
    [<00000000a5ac5a74>] kernel_init_freeable+0x9d4/0xa9c
    [<0000000070ea6c15>] kernel_init+0x18/0x138
    [<00000000fb8fff06>] ret_from_fork+0x10/0x1c
    [<0000000041273a0d>] 0xffffffffffffffff

Then, faddr2line pointed out this line,

/*
 * This memory isn't freed when the device is put,
 * I don't have a nice idea for that though.  Conceptually
 * dma_mask in struct device should not be a pointer.
 * See http://thread.gmane.org/gmane.linux.kernel.pci/9081
 */
pdev->dev.dma_mask =
	kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);

Since this leak has been existed for more than 8-year now and it does not
reference other part of the memory, let kmemleak ignore it, so users don't
need to waste time reporting this in the future.

Signed-off-by: Qian Cai <cai@gmx.us>
---
 drivers/base/platform.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 41b91af..3e1587d 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -26,6 +26,7 @@
 #include <linux/clk/clk-conf.h>
 #include <linux/limits.h>
 #include <linux/property.h>
+#include <linux/kmemleak.h>
 
 #include "base.h"
 #include "power/power.h"
@@ -525,6 +526,8 @@ struct platform_device *platform_device_register_full(
 		if (!pdev->dev.dma_mask)
 			goto err;
 
+		kmemleak_ignore(pdev->dev.dma_mask);
+
 		*pdev->dev.dma_mask = pdevinfo->dma_mask;
 		pdev->dev.coherent_dma_mask = pdevinfo->dma_mask;
 	}
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [RESEND PATCH] drivers/base: kmemleak ignore a known leak
  2018-11-29 15:12 [PATCH] drivers/base: kmemleak ignore a known leak Qian Cai
@ 2018-12-06 16:07 ` Qian Cai
  2018-12-06 17:59   ` Catalin Marinas
  0 siblings, 1 reply; 3+ messages in thread
From: Qian Cai @ 2018-12-06 16:07 UTC (permalink / raw)
  To: akpm; +Cc: gregkh, rafael, catalin.marinas, linux-kernel, Qian Cai

unreferenced object 0xffff808ec6dc5a80 (size 128):
  comm "swapper/0", pid 1, jiffies 4294938063 (age 2560.530s)
  hex dump (first 32 bytes):
    ff ff ff ff 00 00 00 00 6b 6b 6b 6b 6b 6b 6b 6b  ........kkkkkkkk
    6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
  backtrace:
    [<00000000476dcf8c>] kmem_cache_alloc_trace+0x430/0x500
    [<000000004f708d37>] platform_device_register_full+0xbc/0x1e8
    [<000000006c2a7ec7>] acpi_create_platform_device+0x370/0x450
    [<00000000ef135642>] acpi_default_enumeration+0x34/0x78
    [<000000003bd9a052>] acpi_bus_attach+0x2dc/0x3e0
    [<000000003cf4f7f2>] acpi_bus_attach+0x108/0x3e0
    [<000000003cf4f7f2>] acpi_bus_attach+0x108/0x3e0
    [<000000002968643e>] acpi_bus_scan+0xb0/0x110
    [<0000000010dd0bd7>] acpi_scan_init+0x1a8/0x410
    [<00000000965b3c5a>] acpi_init+0x408/0x49c
    [<00000000ed4b9fe2>] do_one_initcall+0x178/0x7f4
    [<00000000a5ac5a74>] kernel_init_freeable+0x9d4/0xa9c
    [<0000000070ea6c15>] kernel_init+0x18/0x138
    [<00000000fb8fff06>] ret_from_fork+0x10/0x1c
    [<0000000041273a0d>] 0xffffffffffffffff

Then, faddr2line pointed out this line,

/*
 * This memory isn't freed when the device is put,
 * I don't have a nice idea for that though.  Conceptually
 * dma_mask in struct device should not be a pointer.
 * See http://thread.gmane.org/gmane.linux.kernel.pci/9081
 */
pdev->dev.dma_mask =
	kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);

Since this leak has been existed for more than 8-year now and it does not
reference other part of the memory, let kmemleak ignore it, so users don't
need to waste time reporting this in the future.

Signed-off-by: Qian Cai <cai@gmx.us>
---
 drivers/base/platform.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 41b91af95afb..3e1587d8320a 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -26,6 +26,7 @@
 #include <linux/clk/clk-conf.h>
 #include <linux/limits.h>
 #include <linux/property.h>
+#include <linux/kmemleak.h>
 
 #include "base.h"
 #include "power/power.h"
@@ -525,6 +526,8 @@ struct platform_device *platform_device_register_full(
 		if (!pdev->dev.dma_mask)
 			goto err;
 
+		kmemleak_ignore(pdev->dev.dma_mask);
+
 		*pdev->dev.dma_mask = pdevinfo->dma_mask;
 		pdev->dev.coherent_dma_mask = pdevinfo->dma_mask;
 	}
-- 
2.17.2 (Apple Git-113)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RESEND PATCH] drivers/base: kmemleak ignore a known leak
  2018-12-06 16:07 ` [RESEND PATCH] " Qian Cai
@ 2018-12-06 17:59   ` Catalin Marinas
  0 siblings, 0 replies; 3+ messages in thread
From: Catalin Marinas @ 2018-12-06 17:59 UTC (permalink / raw)
  To: Qian Cai; +Cc: akpm, gregkh, rafael, linux-kernel

On Thu, Dec 06, 2018 at 11:07:51AM -0500, Qian Cai wrote:
> unreferenced object 0xffff808ec6dc5a80 (size 128):
>   comm "swapper/0", pid 1, jiffies 4294938063 (age 2560.530s)
>   hex dump (first 32 bytes):
>     ff ff ff ff 00 00 00 00 6b 6b 6b 6b 6b 6b 6b 6b  ........kkkkkkkk
>     6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
>   backtrace:
>     [<00000000476dcf8c>] kmem_cache_alloc_trace+0x430/0x500
>     [<000000004f708d37>] platform_device_register_full+0xbc/0x1e8
>     [<000000006c2a7ec7>] acpi_create_platform_device+0x370/0x450
>     [<00000000ef135642>] acpi_default_enumeration+0x34/0x78
>     [<000000003bd9a052>] acpi_bus_attach+0x2dc/0x3e0
>     [<000000003cf4f7f2>] acpi_bus_attach+0x108/0x3e0
>     [<000000003cf4f7f2>] acpi_bus_attach+0x108/0x3e0
>     [<000000002968643e>] acpi_bus_scan+0xb0/0x110
>     [<0000000010dd0bd7>] acpi_scan_init+0x1a8/0x410
>     [<00000000965b3c5a>] acpi_init+0x408/0x49c
>     [<00000000ed4b9fe2>] do_one_initcall+0x178/0x7f4
>     [<00000000a5ac5a74>] kernel_init_freeable+0x9d4/0xa9c
>     [<0000000070ea6c15>] kernel_init+0x18/0x138
>     [<00000000fb8fff06>] ret_from_fork+0x10/0x1c
>     [<0000000041273a0d>] 0xffffffffffffffff
> 
> Then, faddr2line pointed out this line,
> 
> /*
>  * This memory isn't freed when the device is put,
>  * I don't have a nice idea for that though.  Conceptually
>  * dma_mask in struct device should not be a pointer.
>  * See http://thread.gmane.org/gmane.linux.kernel.pci/9081
>  */
> pdev->dev.dma_mask =
> 	kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);
> 
> Since this leak has been existed for more than 8-year now and it does not
> reference other part of the memory, let kmemleak ignore it, so users don't
> need to waste time reporting this in the future.
> 
> Signed-off-by: Qian Cai <cai@gmx.us>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-29 15:12 [PATCH] drivers/base: kmemleak ignore a known leak Qian Cai
2018-12-06 16:07 ` [RESEND PATCH] " Qian Cai
2018-12-06 17:59   ` Catalin Marinas

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git