Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 47c515db authored by Jack Pham's avatar Jack Pham
Browse files

usb: dwc3-msm: Fix memory leak of dwc3 child device



In case of failed probe or driver removal, the dwc3 child device
is left with an extra reference count and hence does not get
cleaned up properly, resulting in a memory leak. kmemleak reports
the following (and others):

unreferenced object 0xffffffdf5934a600 (size 128):
  comm "kworker/2:1", pid 83, jiffies 4294938474 (age 2208.110s)
  hex dump (first 32 bytes):
    00 00 60 0a 00 00 00 00 ff cc 60 0a 00 00 00 00  ..`.......`.....
    a0 5f 2b 7d df ff ff ff 00 02 00 00 00 00 00 00  ._+}............
  backtrace:
    [<ffffff9aeb4a0cb8>] kmemleak_alloc+0x60/0xc0
    [<ffffff9aea63b51c>] __kmalloc+0x220/0x3bc
    [<ffffff9aeafdd5b8>] of_device_alloc+0x98/0x1a8
    [<ffffff9aeafdd87c>] of_platform_device_create_pdata+0x58/0xcc
    [<ffffff9aeafddc38>] of_platform_bus_create+0x220/0x438
    [<ffffff9aeafdded8>] of_platform_populate+0x88/0x104
    [<ffffff9aeacf10f8>] dwc3_msm_probe+0xc7c/0x12f0
    [<ffffff9aeab46514>] platform_drv_probe+0x5c/0xb0
    [<ffffff9aeab43994>] driver_probe_device+0x2e8/0x41c
    [<ffffff9aeab4440c>] __device_attach_driver+0xcc/0x144
    [<ffffff9aeab41b00>] bus_for_each_drv+0x80/0xc8
    [<ffffff9aeab43bf0>] __device_attach+0xa4/0x154
    [<ffffff9aeab43cc0>] device_initial_probe+0x20/0x2c
    [<ffffff9aeab41ca4>] bus_probe_device+0x34/0x8c
    [<ffffff9aeab441a8>] deferred_probe_work_func+0xcc/0x16c
    [<ffffff9aea4d1fe4>] process_one_work+0x1c0/0x3d4

Plug this by adding a call to platform_device_put() which balances
the implicit get_device() from the of_find_device_by_node() call
done during probe.

Change-Id: I1e590cfe14ebbb66005b41f6dfa6a56df9489288
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent a608c0b2
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment