From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Alexey Khoroshilov <khoroshilov@ispras.ru>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>,
Olivier Grenie <olivier.grenie@dibcom.fr>,
Patrick Boettcher <pboettcher@kernellabs.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
ldv-project@ispras.ru
Subject: Re: [PATCH] [media] dib0700: unlock mutexes on error paths
Date: Mon, 19 Mar 2012 14:47:54 -0300 [thread overview]
Message-ID: <4F67714A.3070205@redhat.com> (raw)
In-Reply-To: <1331148118-22593-1-git-send-email-khoroshilov@ispras.ru>
Em 07-03-2012 16:21, Alexey Khoroshilov escreveu:
> dib0700_i2c_xfer [_new and _legacy] leave i2c_mutex locked on error paths.
> The patch adds appropriate unlocks.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
> drivers/media/dvb/dvb-usb/dib0700_core.c | 9 ++++++---
> 1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
> index 070e82a..8ec22c4 100644
> --- a/drivers/media/dvb/dvb-usb/dib0700_core.c
> +++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
> @@ -228,7 +228,7 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
> /* Write request */
> if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
> err("could not acquire lock");
> - return 0;
> + break;
A break here doesn't sound the right thing to do.
> }
> st->buf[0] = REQUEST_NEW_I2C_WRITE;
> st->buf[1] = msg[i].addr << 1;
> @@ -270,11 +270,14 @@ static int dib0700_i2c_xfer_legacy(struct i2c_adapter *adap,
> struct dib0700_state *st = d->priv;
> int i,len;
>
> - if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
> + if (mutex_lock_interruptible(&d->i2c_mutex) < 0) {
> + err("could not acquire lock");
> return -EAGAIN;
> + }
> if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
> + mutex_unlock(&d->i2c_mutex);
> err("could not acquire lock");
> - return 0;
> + return -EAGAIN;
> }
>
> for (i = 0; i < num; i++) {
next prev parent reply other threads:[~2012-03-19 17:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-07 19:21 [PATCH] [media] dib0700: unlock mutexes on error paths Alexey Khoroshilov
2012-03-19 17:47 ` Mauro Carvalho Chehab [this message]
2012-03-19 19:56 ` Alexey Khoroshilov
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=4F67714A.3070205@redhat.com \
--to=mchehab@redhat.com \
--cc=khoroshilov@ispras.ru \
--cc=ldv-project@ispras.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@infradead.org \
--cc=olivier.grenie@dibcom.fr \
--cc=pboettcher@kernellabs.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