android_kernel_motorola_sm6375/drivers/base
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Yang Yingliang b9d179c605 UPSTREAM: driver core: Fix possible memory leak in device_link_add()
I got memory leak as follows:

unreferenced object 0xffff88801f0b2200 (size 64):
  comm "i2c-lis2hh12-21", pid 5455, jiffies 4294944606 (age 15.224s)
  hex dump (first 32 bytes):
    72 65 67 75 6c 61 74 6f 72 3a 72 65 67 75 6c 61  regulator:regula
    74 6f 72 2e 30 2d 2d 69 32 63 3a 31 2d 30 30 31  tor.0--i2c:1-001
  backtrace:
    [<00000000bf5b0c3b>] __kmalloc_track_caller+0x19f/0x3a0
    [<0000000050da42d9>] kvasprintf+0xb5/0x150
    [<000000004bbbed13>] kvasprintf_const+0x60/0x190
    [<00000000cdac7480>] kobject_set_name_vargs+0x56/0x150
    [<00000000bf83f8e8>] dev_set_name+0xc0/0x100
    [<00000000cc1cf7e3>] device_link_add+0x6b4/0x17c0
    [<000000009db9faed>] _regulator_get+0x297/0x680
    [<00000000845e7f2b>] _devm_regulator_get+0x5b/0xe0
    [<000000003958ee25>] st_sensors_power_enable+0x71/0x1b0 [st_sensors]
    [<000000005f450f52>] st_accel_i2c_probe+0xd9/0x150 [st_accel_i2c]
    [<00000000b5f2ab33>] i2c_device_probe+0x4d8/0xbe0
    [<0000000070fb977b>] really_probe+0x299/0xc30
    [<0000000088e226ce>] __driver_probe_device+0x357/0x500
    [<00000000c21dda32>] driver_probe_device+0x4e/0x140
    [<000000004e650441>] __device_attach_driver+0x257/0x340
    [<00000000cf1891b8>] bus_for_each_drv+0x166/0x1e0

When device_register() returns an error, the name allocated in dev_set_name()
will be leaked, the put_device() should be used instead of kfree() to give up
the device reference, then the name will be freed in kobject_cleanup() and the
references of consumer and supplier will be decreased in device_link_release_fn().

Fixes: 287905e68dd2 ("driver core: Expose device link details in sysfs")
Reported-by: Hulk Robot <hulkci@huawei.com>
Reviewed-by: Saravana Kannan <saravanak@google.com>
Reviewed-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20210930085714.2057460-1-yangyingliang@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit df0a18149474c7e6b21f6367fbc6bc8d0f192444)
Bug: 187129171
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: Iba22f7d2f05da2cd24abe157d36fcb4c05b8ee82
2022-01-24 11:41:01 -08:00
..
firmware_loader This is the 5.4.140 stable release 2021-08-12 14:00:44 +02:00
power Merge tag 'android11-5.4.161_r00' into android11-5.4 2022-01-21 08:26:49 +01:00
regmap regmap: Fix possible double-free in regcache_rbtree_exit() 2021-11-02 19:46:13 +01:00
test driver core: Fix test_async_driver_probe if NUMA is disabled 2020-02-01 09:34:36 +00:00
arch_topology.c This is the 5.4.69 stable release 2020-10-01 18:00:35 +02:00
attribute_container.c
base.h UPSTREAM: driver core: Don't do deferred probe in parallel with kernel_init thread 2020-08-06 18:50:43 -07:00
bus.c
cacheinfo.c
class.c
component.c component: Silence bind error on -EPROBE_DEFER 2020-05-27 17:46:31 +02:00
container.c
core.c UPSTREAM: driver core: Fix possible memory leak in device_link_add() 2022-01-24 11:41:01 -08:00
cpu.c x86/speculation: Add Special Register Buffer Data Sampling (SRBDS) mitigation 2020-06-10 20:24:57 +02:00
dd.c This is the 5.4.113 stable release 2021-04-16 12:16:55 +02:00
devcon.c
devcoredump.c
devres.c
devtmpfs.c
driver.c
firmware.c
hypervisor.c
init.c
isa.c
Kconfig
Makefile
map.c
memory.c drivers/base/memory.c: indicate all memory blocks as removable 2020-04-01 11:02:02 +02:00
module.c
node.c This is the 5.4.119 stable release 2021-05-14 10:04:38 +02:00
pinctrl.c
platform-msi.c
platform.c drivers: base: Fix NULL pointer exception in __platform_driver_probe() if a driver developer is foolish 2020-06-24 17:50:24 +02:00
property.c
soc.c
swnode.c software node: Fix node registration 2021-03-17 17:03:48 +01:00
syscore.c
topology.c
transport_class.c