acrn-kernel/drivers/iio/trigger
Yang Yingliang efa17e90e1 iio: trigger: sysfs: fix possible memory leak in iio_sysfs_trig_init()
dev_set_name() allocates memory for name, it need be freed
when device_add() fails, call put_device() to give up the
reference that hold in device_initialize(), so that it can
be freed in kobject_cleanup() when the refcount hit to 0.

Fault injection test can trigger this:

unreferenced object 0xffff8e8340a7b4c0 (size 32):
  comm "modprobe", pid 243, jiffies 4294678145 (age 48.845s)
  hex dump (first 32 bytes):
    69 69 6f 5f 73 79 73 66 73 5f 74 72 69 67 67 65  iio_sysfs_trigge
    72 00 a7 40 83 8e ff ff 00 86 13 c4 f6 ee ff ff  r..@............
  backtrace:
    [<0000000074999de8>] __kmem_cache_alloc_node+0x1e9/0x360
    [<00000000497fd30b>] __kmalloc_node_track_caller+0x44/0x1a0
    [<000000003636c520>] kstrdup+0x2d/0x60
    [<0000000032f84da2>] kobject_set_name_vargs+0x1e/0x90
    [<0000000092efe493>] dev_set_name+0x4e/0x70

Fixes: 1f785681a8 ("staging:iio:trigger sysfs userspace trigger rework.")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20221022074212.1386424-1-yangyingliang@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-10-24 18:48:57 +01:00
..
Kconfig iio: trigger: stm32-timer: Make use of device properties 2022-02-18 11:35:49 +00:00
Makefile
iio-trig-hrtimer.c
iio-trig-interrupt.c iio: interrupt-trigger: Remove no-op trigger ops 2021-11-17 17:51:35 +00:00
iio-trig-loop.c
iio-trig-sysfs.c iio: trigger: sysfs: fix possible memory leak in iio_sysfs_trig_init() 2022-10-24 18:48:57 +01:00
stm32-lptimer-trigger.c iio: trigger: stm32-lptimer-trigger: explicitly add proper header files 2022-06-14 11:53:21 +01:00
stm32-timer-trigger.c iio:adc:stm32*: Use pm[_sleep]_ptr() etc to avoid need to make pm __maybe_unused 2022-02-21 19:33:04 +00:00