public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Alexey Khoroshilov <khoroshilov@ispras.ru>
Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>,
	Hans Verkuil <hans.verkuil@cisco.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	ldv-project@linuxtesting.org
Subject: Re: [PATCH] [media] adv7180: free an interrupt on failure paths in init_device()
Date: Fri, 21 Mar 2014 08:56:14 +0100	[thread overview]
Message-ID: <532BF09E.4050305@metafoo.de> (raw)
In-Reply-To: <1394831043-21425-1-git-send-email-khoroshilov@ispras.ru>

On 03/14/2014 10:04 PM, Alexey Khoroshilov wrote:
> There is request_irq() in init_device(), but the interrupt is not removed
> on failure paths. The patch adds proper error handling.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>

Hi,

Thanks for the patch. It's actually worse than that. request_irq should not 
be called in init_device() since init_device() is also called on resume(). 
The request_irq call should be moved to probe() and be called after init 
device. I've recently made some modifications to this part of the driver 
(switched to threaded IRQs), so make sure you generate the patch against the 
media/master tree.

Thanks,
- Lars

> ---
>   drivers/media/i2c/adv7180.c | 18 +++++++++++-------
>   1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> index d7d99f1c69e4..e462392ba043 100644
> --- a/drivers/media/i2c/adv7180.c
> +++ b/drivers/media/i2c/adv7180.c
> @@ -541,40 +541,44 @@ static int init_device(struct i2c_client *client, struct adv7180_state *state)
>   		ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG,
>   						ADV7180_ADI_CTRL_IRQ_SPACE);
>   		if (ret < 0)
> -			return ret;
> +			goto err;
>
>   		/* config the Interrupt pin to be active low */
>   		ret = i2c_smbus_write_byte_data(client, ADV7180_ICONF1_ADI,
>   						ADV7180_ICONF1_ACTIVE_LOW |
>   						ADV7180_ICONF1_PSYNC_ONLY);
>   		if (ret < 0)
> -			return ret;
> +			goto err;
>
>   		ret = i2c_smbus_write_byte_data(client, ADV7180_IMR1_ADI, 0);
>   		if (ret < 0)
> -			return ret;
> +			goto err;
>
>   		ret = i2c_smbus_write_byte_data(client, ADV7180_IMR2_ADI, 0);
>   		if (ret < 0)
> -			return ret;
> +			goto err;
>
>   		/* enable AD change interrupts interrupts */
>   		ret = i2c_smbus_write_byte_data(client, ADV7180_IMR3_ADI,
>   						ADV7180_IRQ3_AD_CHANGE);
>   		if (ret < 0)
> -			return ret;
> +			goto err;
>
>   		ret = i2c_smbus_write_byte_data(client, ADV7180_IMR4_ADI, 0);
>   		if (ret < 0)
> -			return ret;
> +			goto err;
>
>   		ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG,
>   						0);
>   		if (ret < 0)
> -			return ret;
> +			goto err;
>   	}
>
>   	return 0;
> +
> +err:
> +	free_irq(state->irq, state);
> +	return ret;
>   }
>
>   static int adv7180_probe(struct i2c_client *client,
>


      reply	other threads:[~2014-03-21  7:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-14 21:04 [PATCH] [media] adv7180: free an interrupt on failure paths in init_device() Alexey Khoroshilov
2014-03-21  7:56 ` Lars-Peter Clausen [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=532BF09E.4050305@metafoo.de \
    --to=lars@metafoo.de \
    --cc=hans.verkuil@cisco.com \
    --cc=khoroshilov@ispras.ru \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.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