Re: [patch] iio:dac:ad5449: unlock on error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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@xxxxxxxxxx>
>>
>> Thanks,
>>
>> Acked-by: Lars-Peter Clausen <lars@xxxxxxxxxx>
> 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
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux