patch "iio: temperature: ltc2983: allocate iio channels once" added to char-misc-linus
Subsystems (3)
This is a note to let you know that I've just added the patch titled
iio: temperature: ltc2983: allocate iio channels once
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 4132f19173211856d35180958d2754f5c56d520a Mon Sep 17 00:00:00 2001
From: Cosmin Tanislav <[email protected]>
Date: Fri, 14 Oct 2022 15:37:22 +0300
Subject: iio: temperature: ltc2983: allocate iio channels once
Currently, every time the device wakes up from sleep, the iio_chan array is reallocated, leaking the previous one until the device is removed (basically never).
Move the allocation to the probe function to avoid this.
--- drivers/iio/temperature/ltc2983.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/iio/temperature/ltc2983.c +6 -7
@@ -1385,13 +1385,6 @@ static int ltc2983_setup(struct ltc2983_data *st, bool assign_iio)return ret; } - st->iio_chan =devm_kzalloc (&st->spi->dev, - st->iio_channels *sizeof (*st->iio_chan), -GFP_KERNEL ); - -if (!st->iio_chan) -return -ENOMEM ; - ret =regmap_update_bits (st->regmap,LTC2983_GLOBAL_CONFIG_REG ,LTC2983_NOTCH_FREQ_MASK ,LTC2983_NOTCH_FREQ (st->filter_notch_freq));
@@ -1514,6 +1507,12 @@ static int ltc2983_probe(struct spi_device *spi)gpiod_set_value_cansleep (gpio,0 ); } + st->iio_chan =devm_kzalloc (&spi->dev, + st->iio_channels *sizeof (*st->iio_chan), +GFP_KERNEL ); +if (!st->iio_chan) +return -ENOMEM ; + ret =ltc2983_setup (st, true);if (ret)return ret;
Signature · 1 line
2.38.1