iio: buffer: Fix memory leak in iio_buffer_register_legacy_sysfs_groups()
commit604faf9a2e
upstream. If the second iio_device_register_sysfs_group() fails, 'legacy_buffer_group.attrs' need be freed too or it will cause memory leak: unreferenced object 0xffff888003618280 (size 64): comm "xrun", pid 357, jiffies 4294907259 (age 22.296s) hex dump (first 32 bytes): 80 f6 8c 03 80 88 ff ff 80 fb 8c 03 80 88 ff ff ................ 00 f9 8c 03 80 88 ff ff 80 fc 8c 03 80 88 ff ff ................ backtrace: [<00000000076bfd43>] __kmalloc+0x1a3/0x2f0 [<00000000c32e4886>] iio_buffers_alloc_sysfs_and_mask+0xc31/0x1290 [industrialio] Reported-by: Hulk Robot <hulkci@huawei.com> Fixes:d9a625744e
("iio: core: merge buffer/ & scan_elements/ attributes") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Link: https://lore.kernel.org/r/20211013144242.1685060-1-yangyingliang@huawei.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
289884de9f
Коммит
c32c68ac7b
|
@ -1367,10 +1367,10 @@ static int iio_buffer_register_legacy_sysfs_groups(struct iio_dev *indio_dev,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_free_buffer_attrs:
|
|
||||||
kfree(iio_dev_opaque->legacy_buffer_group.attrs);
|
|
||||||
error_free_scan_el_attrs:
|
error_free_scan_el_attrs:
|
||||||
kfree(iio_dev_opaque->legacy_scan_el_group.attrs);
|
kfree(iio_dev_opaque->legacy_scan_el_group.attrs);
|
||||||
|
error_free_buffer_attrs:
|
||||||
|
kfree(iio_dev_opaque->legacy_buffer_group.attrs);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче