Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Yang Yingliang <yangyingliang@huawei.com>
Cc: <linux-iio@vger.kernel.org>, <mripard@kernel.org>,
	<jonathan.cameron@huawei.com>
Subject: Re: [PATCH] iio: adc: at91_adc: fix possible memory leak in at91_adc_allocate_trigger()
Date: Sat, 29 Oct 2022 13:47:06 +0100	[thread overview]
Message-ID: <20221029134706.5f080004@jic23-huawei> (raw)
In-Reply-To: <20221024084511.815096-1-yangyingliang@huawei.com>

On Mon, 24 Oct 2022 16:45:11 +0800
Yang Yingliang <yangyingliang@huawei.com> wrote:

> If iio_trigger_register() returns error, it should call iio_trigger_free()
> to give up the reference that hold in iio_trigger_alloc(), so that it can
> call iio_trig_release() to free memory when the refcount hit to 0.
> 
> Fixes: 0e589d5fb317 ("ARM: AT91: IIO: Add AT91 ADC driver.")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Seems straight forward so I'm not that bothered about getting extra tags on this.

Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/at91_adc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index 532daaa6f943..366e252ebeb0 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -634,8 +634,10 @@ static struct iio_trigger *at91_adc_allocate_trigger(struct iio_dev *idev,
>  	trig->ops = &at91_adc_trigger_ops;
>  
>  	ret = iio_trigger_register(trig);
> -	if (ret)
> +	if (ret) {
> +		iio_trigger_free(trig);
>  		return NULL;
> +	}
>  
>  	return trig;
>  }


      reply	other threads:[~2022-10-29 12:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-24  8:45 [PATCH] iio: adc: at91_adc: fix possible memory leak in at91_adc_allocate_trigger() Yang Yingliang
2022-10-29 12:47 ` Jonathan Cameron [this message]

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=20221029134706.5f080004@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=mripard@kernel.org \
    --cc=yangyingliang@huawei.com \
    /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