Bug 120331 - kmemleak: 1 new suspected memory leaks
Summary: kmemleak: 1 new suspected memory leaks
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Other (show other bugs)
Hardware: PPC-32 Linux
: P1 normal
Assignee: drivers_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-15 08:48 UTC by Mathieu Malaterre
Modified: 2019-06-07 06:17 UTC (History)
2 users (show)

See Also:
Kernel Version: 4.5.5
Tree: Mainline
Regression: No


Attachments
Test Patch (838 bytes, patch)
2016-07-19 21:12 UTC, [account disabled by administrator]
Details | Diff

Description Mathieu Malaterre 2016-06-15 08:48:19 UTC
I keep getting memleak report on my PowerPC (Mac Mini G4) system.

$ sudo cat /sys/kernel/debug/kmemleak
unreferenced object 0xdf532e60 (size 32):
  comm "swapper", pid 1, jiffies 4294892300 (age 3148.652s)
  hex dump (first 32 bytes):
    6c 32 2d 63 61 63 68 65 23 31 00 dd e4 df 1e c2  l2-cache#1......
    e8 d4 ba ce 04 fe cd de 8e 85 e9 4b c6 ec c4 92  ...........K....
  backtrace:
    [<c02d3350>] kvasprintf+0x64/0xc8
    [<c02d3400>] kasprintf+0x4c/0x5c
    [<c0453814>] safe_name.isra.1+0x80/0xc4
    [<c04545d8>] __of_attach_node_sysfs+0x6c/0x11c
    [<c075f21c>] of_core_init+0x8c/0xf8
    [<c0729594>] kernel_init_freeable+0xd4/0x208
    [<c00047e8>] kernel_init+0x24/0x11c
    [<c00158ec>] ret_from_kernel_thread+0x5c/0x64


It would be nice to check `safe_name` is freed in all cases.
Comment 1 Mathieu Malaterre 2016-06-15 09:51:44 UTC
Forgot to mention, the leak appears after each reboot.

[...]
[   16.857534] input: Mouseemu virtual mouse as /devices/virtual/input/input6
[   16.857576] device: 'mouse1': device_add
[   16.857653] PM: Adding info for No Bus:mouse1
[   16.859514] device: 'event6': device_add
[   16.859609] PM: Adding info for No Bus:event6
[  661.316052] kmemleak: 1 new suspected memory leaks (see /sys/kernel/debug/kmemleak)
[...]

unreferenced object 0xdf532e60 (size 32):
  comm "swapper", pid 1, jiffies 4294892300 (age 1993.532s)
  hex dump (first 32 bytes):
    6c 32 2d 63 61 63 68 65 23 31 00 dd e4 dd 1e c2  l2-cache#1......
    ec d4 ba ce 04 ec cc de 8e 85 e9 ca c4 ec cc 9e  ................
  backtrace:
    [<c02d3350>] kvasprintf+0x64/0xc8
    [<c02d3400>] kasprintf+0x4c/0x5c
    [<c0453814>] safe_name.isra.1+0x80/0xc4
    [<c04545d8>] __of_attach_node_sysfs+0x6c/0x11c
    [<c075f21c>] of_core_init+0x8c/0xf8
    [<c0729594>] kernel_init_freeable+0xd4/0x208
    [<c00047e8>] kernel_init+0x24/0x11c
    [<c00158ec>] ret_from_kernel_thread+0x5c/0x64
Comment 2 Mathieu Malaterre 2016-06-15 09:53:16 UTC
I believe this might help in tracking the leak:

[    0.023043] device-tree: Duplicate name in PowerPC,G4@0, renamed to "l2-cache#1"
Comment 3 [account disabled by administrator] 2016-07-19 21:12:10 UTC
See if the below patch fixes your memory leak.
Comment 4 [account disabled by administrator] 2016-07-19 21:12:27 UTC
Created attachment 224311 [details]
Test Patch
Comment 5 Mathieu Malaterre 2016-07-20 05:54:01 UTC
Right :) How do I say it politely:

[...]
kfree(name);

return name;
[...]

Anyway the real patch can be found here:

https://patchwork.kernel.org/patch/9179049/

I am not sure why this was not approved yet.
Comment 6 Mathieu Malaterre 2016-07-20 05:57:31 UTC
Ooops, apparently this was merged:

https://lkml.org/lkml/2016/6/24/616
Comment 7 [account disabled by administrator] 2016-07-20 06:34:24 UTC
Then close this bug as fixed and no longer a known but fixed bug.
Comment 8 Mathieu Malaterre 2019-06-07 06:17:52 UTC
d9fc88072332 of: fix memory leak related to safe_name()

Note You need to log in before you can comment on or make changes to this bug.