mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 08:58:07 +00:00
b6ca770ae7
UFS drivers that probe defer will end up leaking memory allocated for clk and regulator names via kstrdup() because the structure that is holding this memory is allocated via devm_* variants which will be freed during probe defer but the names are never freed. Use same devm_* variant of kstrdup to free the memory allocated to name when driver probe defers. Kmemleak found around 11 leaks on Qualcomm Dragon Board RB5: unreferenced object 0xffff66f243fb2c00 (size 128): comm "kworker/u16:0", pid 7, jiffies 4294893319 (age 94.848s) hex dump (first 32 bytes): 63 6f 72 65 5f 63 6c 6b 00 76 69 72 74 75 61 6c core_clk.virtual 2f 77 6f 72 6b 71 75 65 75 65 2f 73 63 73 69 5f /workqueue/scsi_ backtrace: [<000000006f788cd1>] slab_post_alloc_hook+0x88/0x410 [<00000000cfd1372b>] __kmalloc_track_caller+0x138/0x230 [<00000000a92ab17b>] kstrdup+0xb0/0x110 [<0000000037263ab6>] ufshcd_pltfrm_init+0x1a8/0x500 [<00000000a20a5caa>] ufs_qcom_probe+0x20/0x58 [<00000000a5e43067>] platform_probe+0x6c/0x118 [<00000000ef686e3f>] really_probe+0xc4/0x330 [<000000005b18792c>] __driver_probe_device+0x88/0x118 [<00000000a5d295e8>] driver_probe_device+0x44/0x158 [<000000007e83f58d>] __device_attach_driver+0xb4/0x128 [<000000004bfa4470>] bus_for_each_drv+0x68/0xd0 [<00000000b89a83bc>] __device_attach+0xec/0x170 [<00000000ada2beea>] device_initial_probe+0x14/0x20 [<0000000079921612>] bus_probe_device+0x9c/0xa8 [<00000000d268bf7c>] deferred_probe_work_func+0x90/0xd0 [<000000009ef64bfa>] process_one_work+0x29c/0x788 unreferenced object 0xffff66f243fb2c80 (size 128): comm "kworker/u16:0", pid 7, jiffies 4294893319 (age 94.848s) hex dump (first 32 bytes): 62 75 73 5f 61 67 67 72 5f 63 6c 6b 00 00 00 00 bus_aggr_clk.... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ With this patch no memory leaks are reported. Link: https://lore.kernel.org/r/20210914092214.6468-1-srinivas.kandagatla@linaro.org Fixes: |
||
---|---|---|
.. | ||
cdns-pltfrm.c | ||
Kconfig | ||
Makefile | ||
tc-dwc-g210-pci.c | ||
tc-dwc-g210-pltfrm.c | ||
tc-dwc-g210.c | ||
tc-dwc-g210.h | ||
ti-j721e-ufs.c | ||
ufs-debugfs.c | ||
ufs-debugfs.h | ||
ufs-exynos.c | ||
ufs-exynos.h | ||
ufs-fault-injection.c | ||
ufs-fault-injection.h | ||
ufs-hisi.c | ||
ufs-hisi.h | ||
ufs-hwmon.c | ||
ufs-mediatek-trace.h | ||
ufs-mediatek.c | ||
ufs-mediatek.h | ||
ufs-qcom-ice.c | ||
ufs-qcom.c | ||
ufs-qcom.h | ||
ufs-sysfs.c | ||
ufs-sysfs.h | ||
ufs.h | ||
ufs_bsg.c | ||
ufs_bsg.h | ||
ufs_quirks.h | ||
ufshcd-crypto.c | ||
ufshcd-crypto.h | ||
ufshcd-dwc.c | ||
ufshcd-dwc.h | ||
ufshcd-pci.c | ||
ufshcd-pltfrm.c | ||
ufshcd-pltfrm.h | ||
ufshcd.c | ||
ufshcd.h | ||
ufshci-dwc.h | ||
ufshci.h | ||
ufshpb.c | ||
ufshpb.h | ||
unipro.h |