Yang Yingliang
9a2ff8009e
iio: buffer: Fix memory leak in __iio_buffer_alloc_sysfs_and_mask()
When iio_buffer_wrap_attr() returns NULL or buffer->buffer_group.name alloc
fails, the 'attr' which is allocated in __iio_buffer_alloc_sysfs_and_mask()
is not freed, and cause memory leak.
unreferenced object 0xffff888014882a00 (size 64):
comm "i2c-adjd_s311-8", pid 424, jiffies 4294907737 (age 44.396s)
hex dump (first 32 bytes):
00 0f 8a 15 80 88 ff ff 00 0e 8a 15 80 88 ff ff ................
80 04 8a 15 80 88 ff ff 80 05 8a 15 80 88 ff ff ................
backtrace:
[<0000000021752e67>] __kmalloc+0x1af/0x3c0
[<0000000043e8305c>] iio_buffers_alloc_sysfs_and_mask+0xe73/0x1570 [industrialio]
[<00000000b7aa5a17>] __iio_device_register+0x483/0x1a30 [industrialio]
[<000000003fa0fb2f>] __devm_iio_device_register+0x23/0x90 [industrialio]
[<000000003ab040cf>] adjd_s311_probe+0x19c/0x200 [adjd_s311]
[<0000000080458969>] i2c_device_probe+0xa31/0xbe0
[<00000000e20678ad>] really_probe+0x299/0xc30
[<000000006bea9b27>] __driver_probe_device+0x357/0x500
[<00000000e1df10d4>] driver_probe_device+0x4e/0x140
[<0000000003661beb>] __device_attach_driver+0x257/0x340
[<000000005bb4aa26>] bus_for_each_drv+0x166/0x1e0
[<00000000272c5236>] __device_attach+0x272/0x420
[<00000000d52a96ae>] bus_probe_device+0x1eb/0x2a0
[<00000000129f7737>] device_add+0xbf0/0x1f90
[<000000005eed4e52>] i2c_new_client_device+0x622/0xb20
[<00000000b85a9c43>] new_device_store+0x1fa/0x420
This patch fix to free it before the error return.
Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: 15097c7a1a ("iio: buffer: wrap all buffer attributes into iio_dev_attr")
Fixes: d9a625744e ("iio: core: merge buffer/ & scan_elements/ attributes")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20211013094343.315275-1-yangyingliang@huawei.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-17 15:15:29 +01:00
..
2021-09-23 20:39:36 +02:00
2021-09-14 09:02:13 +02:00
2021-09-03 08:06:02 -06:00
2021-09-24 11:20:29 -07:00
2021-09-01 08:44:42 -07:00
2021-09-11 14:48:42 -07:00
2021-08-19 17:08:31 +02:00
2021-09-01 15:25:28 -07:00
2021-09-12 11:44:58 -07:00
2021-09-11 10:05:56 -07:00
2021-09-03 11:11:54 -07:00
2021-09-21 17:53:54 +02:00
2021-09-17 12:05:04 -07:00
2021-09-07 12:38:59 -07:00
2021-09-07 19:13:42 -07:00
2021-09-09 11:48:27 -07:00
2021-09-09 11:39:57 -07:00
2021-09-08 11:50:26 -07:00
2021-09-09 11:07:47 -07:00
2021-09-07 12:42:21 +05:30
2021-09-16 11:00:12 +02:00
2021-09-11 09:47:33 -07:00
2021-09-11 09:20:57 -07:00
2021-09-16 15:20:55 -07:00
2021-09-22 11:31:52 +02:00
2021-09-24 10:14:19 -07:00
2021-09-02 14:30:46 -07:00
2021-09-15 17:18:56 -07:00
2021-09-08 12:55:35 -07:00
2021-09-14 09:03:16 +02:00
2021-09-02 13:49:39 -07:00
2021-10-17 15:15:29 +01:00
2021-09-09 11:14:14 -07:00
2021-09-11 09:08:28 -07:00
2021-08-24 15:33:04 +02:00
2021-09-11 14:48:42 -07:00
2021-09-01 09:51:16 -07:00
2021-09-22 14:44:25 +01:00
2021-09-03 15:33:47 -07:00
2021-08-20 11:00:08 +02:00
2021-09-14 13:23:22 -07:00
2021-08-31 22:57:45 -05:00
2021-09-14 11:22:26 +02:00
2021-09-22 08:45:58 -07:00
2021-09-08 12:55:35 -07:00
2021-09-01 08:44:42 -07:00
2021-09-07 12:38:59 -07:00
2021-09-21 16:17:15 +02:00
2021-09-03 10:08:28 -07:00
2021-09-08 12:55:35 -07:00
2021-09-23 10:30:31 -07:00
2021-09-23 12:53:06 +01:00
2021-09-07 13:05:02 -07:00
2021-09-09 11:48:27 -07:00
2021-09-21 09:17:15 +02:00
2021-09-21 17:38:37 +02:00
2021-09-17 15:58:09 -05:00
2021-08-30 19:25:42 +02:00
2021-09-09 12:44:31 +02:00
2021-09-02 13:16:00 -07:00
2021-09-25 15:37:31 -07:00
2021-09-08 12:55:35 -07:00
2021-09-03 15:33:47 -07:00
2021-09-21 15:49:23 +02:00
2021-08-30 11:47:32 -07:00
2021-08-25 20:12:16 +02:00
2021-09-20 11:11:54 +01:00
2021-09-02 22:27:46 +02:00
2021-09-17 13:16:38 +01:00
2021-09-01 15:25:28 -07:00
2021-09-14 10:20:19 +02:00
2021-09-23 10:30:31 -07:00
2021-09-22 00:36:40 -04:00
2021-09-01 08:44:42 -07:00
2021-09-01 15:25:28 -07:00
2021-09-01 10:29:29 -07:00
2021-09-22 11:58:24 -07:00
2021-10-05 12:35:30 +02:00
2021-09-22 00:17:29 -04:00
2021-09-21 15:17:11 +02:00
2021-09-06 12:27:03 -07:00
2021-09-14 11:18:47 +02:00
2021-09-24 10:22:53 +02:00
2021-09-11 14:48:42 -07:00
2021-09-02 13:41:33 -07:00
2021-09-16 13:05:42 -07:00
2021-09-18 11:15:01 -07:00
2021-09-11 14:48:42 -07:00
2021-08-22 10:28:12 +02:00
2021-09-25 15:37:31 -07:00