patch "iio: accel: kxcjk-1013: Fix possible memory leak in probe and remove" added to char-misc-linus
Subsystems (2)
This is a note to let you know that I've just added the patch titled
iio: accel: kxcjk-1013: Fix possible memory leak in probe and remove
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 70c9774e180d151abaab358108e3510a8e615215 Mon Sep 17 00:00:00 2001
From: Yang Yingliang <[email protected]>
Date: Mon, 25 Oct 2021 20:41:59 +0800
Subject: iio: accel: kxcjk-1013: Fix possible memory leak in probe and remove
When ACPI type is ACPI_SMO8500, the data->dready_trig will not be set, the memory allocated by iio_triggered_buffer_setup() will not be freed, and cause memory leak as follows:
unreferenced object 0xffff888009551400 (size 512):
comm "i2c-SMO8500-125", pid 911, jiffies 4294911787 (age 83.852s) hex dump (first 32 bytes):
02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 20 e2 e5 c0 ff ff ff ff ........ .......
backtrace:
[<0000000041ce75ee>] kmem_cache_alloc_trace+0x16d/0x360
[<000000000aeb17b0>] iio_kfifo_allocate+0x41/0x130 [kfifo_buf]
[<000000004b40c1f5>] iio_triggered_buffer_setup_ext+0x2c/0x210 [industrialio_triggered_buffer]
[<000000004375b15f>] kxcjk1013_probe+0x10c3/0x1d81 [kxcjk_1013]Fix it by remove data->dready_trig condition in probe and remove.
--- drivers/iio/accel/kxcjk-1013.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/accel/kxcjk-1013.c +2 -3
@@ -1595,8 +1595,7 @@ static int kxcjk1013_probe(struct i2c_client *client,return 0 ; err_buffer_cleanup: -if (data->dready_trig) -iio_triggered_buffer_cleanup (indio_dev); +iio_triggered_buffer_cleanup (indio_dev); err_trigger_unregister:if (data->dready_trig)iio_trigger_unregister (data->dready_trig);
@@ -1618,8 +1617,8 @@ static int kxcjk1013_remove(struct i2c_client *client)pm_runtime_disable (&client->dev);pm_runtime_set_suspended (&client->dev); +iio_triggered_buffer_cleanup (indio_dev);if (data->dready_trig) { -iio_triggered_buffer_cleanup (indio_dev);iio_trigger_unregister (data->dready_trig);iio_trigger_unregister (data->motion_trig); }
Signature · 1 line
2.34.1