patch "iio: core: fix memleak in iio_device_register_sysfs" added to char-misc-linus
Subsystems (2)
This is a note to let you know that I've just added the patch titled
iio: core: fix memleak in iio_device_register_sysfs
to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From 95a0d596bbd0552a78e13ced43f2be1038883c81 Mon Sep 17 00:00:00 2001
From: Dinghao Liu <[email protected]>
Date: Fri, 8 Dec 2023 15:31:19 +0800
Subject: iio: core: fix memleak in iio_device_register_sysfs
When iio_device_register_sysfs_group() fails, we should free iio_dev_opaque->chan_attr_group.attrs to prevent potential memleak.
--- drivers/iio/industrialio-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/industrialio-core.c +4 -1
@@ -1584,10 +1584,13 @@ static int iio_device_register_sysfs(struct iio_dev *indio_dev) ret =iio_device_register_sysfs_group (indio_dev, &iio_dev_opaque->chan_attr_group);if (ret) - goto error_clear_attrs; + goto error_free_chan_attrs;return 0 ; +error_free_chan_attrs: +kfree (iio_dev_opaque->chan_attr_group.attrs); + iio_dev_opaque->chan_attr_group.attrs =NULL ; error_clear_attrs:iio_free_chan_devattr_list (&iio_dev_opaque->channel_attr_list);
Signature · 1 line
2.43.1