linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Jonathan Cameron <jic23@cam.ac.uk>,
	linux-iio@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] iio:dac:ad5449: unlock on error path
Date: Fri, 02 Nov 2012 17:52:26 +0100	[thread overview]
Message-ID: <5093FA4A.2010006@bfs.de> (raw)
In-Reply-To: <5093A93D.70302@kernel.org>



Am 02.11.2012 12:06, schrieb Jonathan Cameron:
> On 10/24/2012 09:22 AM, Lars-Peter Clausen wrote:
>> On 10/24/2012 09:13 AM, Dan Carpenter wrote:
>>> There is an unlock missing on this error path.
>>>
>>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>>
>> Thanks,
>>
>> Acked-by: Lars-Peter Clausen <lars@metafoo.de>
> Thanks applied to togreg branch of
> git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
> 
>>
>>> ---
>>> Only needed in linux-next.
>>>
>>> diff --git a/drivers/iio/dac/ad5449.c b/drivers/iio/dac/ad5449.c
>>> index 5b43030..0ee6f8e 100644
>>> --- a/drivers/iio/dac/ad5449.c
>>> +++ b/drivers/iio/dac/ad5449.c
>>> @@ -124,12 +124,13 @@ static int ad5449_read(struct iio_dev *indio_dev, unsigned int addr,
>>>  
>>>  	ret = spi_sync(st->spi, &msg);
>>>  	if (ret < 0)
>>> -		return ret;
>>> +		goto out_unlock;
>>>  
>>>  	*val = be16_to_cpu(st->data[1]);
>>> -	mutex_unlock(&indio_dev->mlock);
>>>  
>>> -	return 0;
>>> +out_unlock:
>>> +	mutex_unlock(&indio_dev->mlock);
>>> +	return ret;
>>>  }
>>>  
>>>  static int ad5449_read_raw(struct iio_dev *indio_dev,
>>> --


if i understand the code correct you can simply the flow
by turning the check on its head.

ret = spi_sync(st->spi, &msg);
if (ret>=0)
    *val = be16_to_cpu(st->data[1]);
mutex_unlock(&indio_dev->mlock);
return ret;

re,
 wh

  reply	other threads:[~2012-11-02 16:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-24  7:13 [patch] iio:dac:ad5449: unlock on error path Dan Carpenter
2012-10-24  8:22 ` Lars-Peter Clausen
2012-11-02 11:06   ` Jonathan Cameron
2012-11-02 16:52     ` walter harms [this message]
2012-11-05  6:38       ` Dan Carpenter

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=5093FA4A.2010006@bfs.de \
    --to=wharms@bfs.de \
    --cc=dan.carpenter@oracle.com \
    --cc=jic23@cam.ac.uk \
    --cc=jic23@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@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;
as well as URLs for NNTP newsgroup(s).