mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-16 12:14:06 +00:00
iio: fix memory leak in iio_device_register_eventset()
When iio_device_register_sysfs_group() returns failed,
iio_device_register_eventset() needs to free attrs array.
Otherwise, kmemleak would scan & report memory leak as below:
unreferenced object 0xffff88810a1cc3c0 (size 32):
comm "100-i2c-vcnl302", pid 728, jiffies 4295052307 (age 156.027s)
backtrace:
__kmalloc+0x46/0x1b0
iio_device_register_eventset at drivers/iio/industrialio-event.c:541
__iio_device_register at drivers/iio/industrialio-core.c:1959
__devm_iio_device_register at drivers/iio/industrialio-core.c:2040
Fixes: 32f171724e
("iio: core: rework iio device group creation")
Signed-off-by: Zeng Heng <zengheng4@huawei.com>
Link: https://lore.kernel.org/r/20221115023712.3726854-1-zengheng4@huawei.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
398e347987
commit
86fdd15e10
1 changed files with 3 additions and 1 deletions
|
@ -556,7 +556,7 @@ int iio_device_register_eventset(struct iio_dev *indio_dev)
|
|||
|
||||
ret = iio_device_register_sysfs_group(indio_dev, &ev_int->group);
|
||||
if (ret)
|
||||
goto error_free_setup_event_lines;
|
||||
goto error_free_group_attrs;
|
||||
|
||||
ev_int->ioctl_handler.ioctl = iio_event_ioctl;
|
||||
iio_device_ioctl_handler_register(&iio_dev_opaque->indio_dev,
|
||||
|
@ -564,6 +564,8 @@ int iio_device_register_eventset(struct iio_dev *indio_dev)
|
|||
|
||||
return 0;
|
||||
|
||||
error_free_group_attrs:
|
||||
kfree(ev_int->group.attrs);
|
||||
error_free_setup_event_lines:
|
||||
iio_free_chan_devattr_list(&ev_int->dev_attr_list);
|
||||
kfree(ev_int);
|
||||
|
|
Loading…
Add table
Reference in a new issue