lkml.org 
[lkml]   [2022]   [Oct]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] iio: temperature: ltc2983: allocate iio channels once
On Fri, 14 Oct 2022 16:18:24 +0100
Jonathan Cameron <Jonathan.Cameron@huawei.com> wrote:

> On Fri, 14 Oct 2022 15:11:47 +0100
> Jonathan Cameron <Jonathan.Cameron@huawei.com> wrote:
>
> > On Fri, 14 Oct 2022 15:37:22 +0300
> > Cosmin Tanislav <demonsingur@gmail.com> wrote:
> >
> > > From: Cosmin Tanislav <cosmin.tanislav@analog.com>
> > >
> > > 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.
> > >
> > > Signed-off-by: Cosmin Tanislav <cosmin.tanislav@analog.com>
> > Hi Cosmin,
> >
> > Please give a fixes tag for this one as we'll definitely want to
> > backport it.
> >
> > Reply to this patch is fine as b4 will pick it up like any other tag.
> Fixes: f110f3188e563 ("iio: temperature: Add support for LTC2983")
>
> (from direct mail)
>
Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

> >
> > > ---
> > > drivers/iio/temperature/ltc2983.c | 13 ++++++-------
> > > 1 file changed, 6 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c
> > > index b652d2b39bcf..a60ccf183687 100644
> > > --- a/drivers/iio/temperature/ltc2983.c
> > > +++ b/drivers/iio/temperature/ltc2983.c
> > > @@ -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;
> >
> >
>

\
 
 \ /
  Last update: 2022-10-15 18:35    [W:0.049 / U:1.592 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site