Title: [9314] trunk/drivers/staging/iio/magnetometer/hmc5843.c: drivers/staging/iio: call mutex_unlock in error handling code
- Revision
- 9314
- Author
- vapier
- Date
- 2010-10-24 16:23:49 -0400 (Sun, 24 Oct 2010)
Log Message
drivers/staging/iio: call mutex_unlock in error handling code
From: Julia Lawall <[email protected]>
Adjust the error handling code so that it benefits from the call to
mutex_unlock at the end of the function.
The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@rcu exists@
position p1;
_expression_ E;
@@
mutex_l...@p1(E);
...
mutex_unlock(E);
@exists@
position rcu.p1;
_expression_ E;
@@
*mutex_l...@p1(E);
... when != mutex_unlock(E);
?*return ...;
// </smpl>
Modified Paths
Diff
Modified: trunk/drivers/staging/iio/magnetometer/hmc5843.c (9313 => 9314)
--- trunk/drivers/staging/iio/magnetometer/hmc5843.c 2010-10-24 18:13:31 UTC (rev 9313)
+++ trunk/drivers/staging/iio/magnetometer/hmc5843.c 2010-10-24 20:23:49 UTC (rev 9314)
@@ -220,11 +220,15 @@
int error;
mutex_lock(&data->lock);
error = strict_strtoul(buf, 10, &operating_mode);
- if (error)
- return error;
+ if (error) {
+ count = error;
+ goto exit;
+ }
dev_dbg(dev, "set Conversion mode to %lu\n", operating_mode);
- if (operating_mode > MODE_SLEEP)
- return -EINVAL;
+ if (operating_mode > MODE_SLEEP) {
+ count = -EINVAL;
+ goto exit;
+ }
status = i2c_smbus_write_byte_data(client, this_attr->address,
operating_mode);
@@ -437,18 +441,23 @@
int error;
mutex_lock(&data->lock);
error = strict_strtoul(buf, 10, &range);
- if (error)
- return error;
+ if (error) {
+ count = error;
+ goto exit;
+ }
dev_dbg(dev, "set range to %lu\n", range);
- if (range > RANGE_6_5)
- return -EINVAL;
+ if (range > RANGE_6_5) {
+ count = -EINVAL;
+ goto exit;
+ }
data->range = range;
range = range << RANGE_GAIN_OFFSET;
if (i2c_smbus_write_byte_data(client, this_attr->address, range))
count = -EINVAL;
+exit:
mutex_unlock(&data->lock);
return count;
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits