Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Johannes Thumshirn <johannes.thumshirn@men.de>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: adc: men_z188_adc: Fix a resource leak in an error handling path
Date: Sun, 30 Jan 2022 13:51:55 +0000	[thread overview]
Message-ID: <20220130135155.024e08a2@jic23-huawei> (raw)
In-Reply-To: <320fc777863880247c2aff4a9d1a54ba69abf080.1643445149.git.christophe.jaillet@wanadoo.fr>

On Sat, 29 Jan 2022 09:32:47 +0100
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:

> If iio_device_register() fails, a previous ioremap() is left unbalanced.
> 
> Update the error handling path and add the missing iounmap() call, as
> already done in the remove function.
> 
> Fixes: 74aeac4da66f ("iio: adc: Add MEN 16z188 ADC driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
This is a good target for a devm_ conversion at somepoint, but this
is indeed the minimal fix so we should do this first.

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

Thanks,

Jonathan

> ---
>  drivers/iio/adc/men_z188_adc.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/men_z188_adc.c b/drivers/iio/adc/men_z188_adc.c
> index 42ea8bc7e780..adc5ceaef8c9 100644
> --- a/drivers/iio/adc/men_z188_adc.c
> +++ b/drivers/iio/adc/men_z188_adc.c
> @@ -103,6 +103,7 @@ static int men_z188_probe(struct mcb_device *dev,
>  	struct z188_adc *adc;
>  	struct iio_dev *indio_dev;
>  	struct resource *mem;
> +	int ret;
>  
>  	indio_dev = devm_iio_device_alloc(&dev->dev, sizeof(struct z188_adc));
>  	if (!indio_dev)
> @@ -128,8 +129,14 @@ static int men_z188_probe(struct mcb_device *dev,
>  	adc->mem = mem;
>  	mcb_set_drvdata(dev, indio_dev);
>  
> -	return iio_device_register(indio_dev);
> +	ret = iio_device_register(indio_dev);
> +	if (ret)
> +		goto err_unmap;
> +
> +	return 0;
>  
> +err_unmap:
> +	iounmap(adc->base);
>  err:
>  	mcb_release_mem(mem);
>  	return -ENXIO;


      reply	other threads:[~2022-01-30 13:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-29  8:32 [PATCH] iio: adc: men_z188_adc: Fix a resource leak in an error handling path Christophe JAILLET
2022-01-30 13:51 ` 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=20220130135155.024e08a2@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=gregkh@linuxfoundation.org \
    --cc=johannes.thumshirn@men.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.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