devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Cosmin Tanislav <demonsingur@gmail.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Cosmin Tanislav" <cosmin.tanislav@analog.com>
Subject: Re: [PATCH v2 1/5] iio: temperature: ltc2983: allocate iio channels once
Date: Sun, 23 Oct 2022 13:40:48 +0100	[thread overview]
Message-ID: <20221023134048.5a1dd6d9@jic23-huawei> (raw)
In-Reply-To: <20221020090257.1717053-2-demonsingur@gmail.com>

On Thu, 20 Oct 2022 12:02:53 +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.
> 
> Fixes: f110f3188e56 ("iio: temperature: Add support for LTC2983")
> Signed-off-by: Cosmin Tanislav <cosmin.tanislav@analog.com>
Note I already have this queued as a fix and I've sent the pull request to Greg this
morning.  For future versions of this series, maybe just put a note in the cover
letter to cover the dependency.

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;


  reply	other threads:[~2022-10-23 12:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20  9:02 [PATCH v2 0/5] Support more parts in LTC2983 Cosmin Tanislav
2022-10-20  9:02 ` [PATCH v2 1/5] iio: temperature: ltc2983: allocate iio channels once Cosmin Tanislav
2022-10-23 12:40   ` Jonathan Cameron [this message]
2022-10-20  9:02 ` [PATCH v2 2/5] iio: temperature: ltc2983: make bulk write buffer DMA-safe Cosmin Tanislav
2022-10-23 12:42   ` Jonathan Cameron
2022-10-24  6:35     ` Sa, Nuno
2022-10-20  9:02 ` [PATCH v2 3/5] dt-bindings: iio: temperature: ltc2983: refine Cosmin Tanislav
2022-10-20 12:56   ` Rob Herring
2022-10-23 12:51   ` Jonathan Cameron
2022-10-23 13:46     ` Nuno Sá
2022-10-24 16:44       ` Jonathan Cameron
2022-10-20  9:02 ` [PATCH v2 4/5] dt-bindings: iio: temperature: ltc2983: support more parts Cosmin Tanislav
2022-10-20  9:02 ` [PATCH v2 5/5] " Cosmin Tanislav
2022-10-23 12:54   ` Jonathan Cameron
2022-10-24  6:37     ` Sa, Nuno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221023134048.5a1dd6d9@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=cosmin.tanislav@analog.com \
    --cc=demonsingur@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).