Skip to contentSkip to conversation

mfd: twl4030: Fix mismatch in mutex lock-unlock

PATCH In review Sanjeev Premi 3 participants 4 messages Jul 11, 2011 – Jul 27, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mfd: twl4030: Fix mismatch in mutex lock-unlock

A mutex is locked on entry into twl4030_madc_conversion(). Immediate return on some error conditions leaves the mutex locked.

This patch ensures that mutex is always unlocked before leaving the function.

---

Compile tested only.

Changes since v1:
None. Repost after adding Samuel Ortiz to cc: and removed lm-sensors list from to: list.

 drivers/mfd/twl4030-madc.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/mfd/twl4030-madc.c +4 -4
index 3941ddc..b5d598c 100644
@@ -530,13 +530,13 @@ int twl4030_madc_conversion(struct twl4030_madc_request *req)
 	if (ret) {
 		dev_err(twl4030_madc->dev,
 			"unable to write sel register 0x%X\n", method->sel + 1);
-		return ret;
+		goto out;
 	}
 	ret = twl_i2c_write_u8(TWL4030_MODULE_MADC, ch_lsb, method->sel);
 	if (ret) {
 		dev_err(twl4030_madc->dev,
 			"unable to write sel register 0x%X\n", method->sel + 1);
-		return ret;
+		goto out;
 	}
 	/* Select averaging for all channels if do_avg is set */
 	if (req->do_avg) {
@@ -546,7 +546,7 @@ int twl4030_madc_conversion(struct twl4030_madc_request *req)
 			dev_err(twl4030_madc->dev,
 				"unable to write avg register 0x%X\n",
 				method->avg + 1);
-			return ret;
+			goto out;
 		}
 		ret = twl_i2c_write_u8(TWL4030_MODULE_MADC,
 				       ch_lsb, method->avg);
@@ -554,7 +554,7 @@ int twl4030_madc_conversion(struct twl4030_madc_request *req)
 			dev_err(twl4030_madc->dev,
 				"unable to write sel reg 0x%X\n",
 				method->sel + 1);
-			return ret;
+			goto out;
 		}
 	}
 	if (req->type == TWL4030_MADC_IRQ_ONESHOT && req->func_cb != NULL) {
Signature · 1 line
1.7.2.2
#1 lore raw

Hi Sanjeev,

Thanks. Changes look good to me.

Quoted 63 lines · Sanjeev Premi

A mutex is locked on entry into twl4030_madc_conversion(). Immediate return on some error conditions leaves the mutex locked.

This patch ensures that mutex is always unlocked before leaving the function.

---

 Compile tested only.

 Changes since v1:
  None. Repost after adding Samuel Ortiz to cc: and removed lm-sensors list from to: list.

 drivers/mfd/twl4030-madc.c |    8 ++++----

 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/mfd/twl4030-madc.c +4 -5
index 3941ddc..b5d598c 100644
@@ -530,13 +530,13 @@ int twl4030_madc_conversion(struct twl4030_madc_request *req)
        if (ret) {
                dev_err(twl4030_madc->dev,
                        "unable to write sel register 0x%X\n", method->sel + 1);
-               return ret;
+               goto out;
        }
        ret = twl_i2c_write_u8(TWL4030_MODULE_MADC, ch_lsb, method->sel);
        if (ret) {
                dev_err(twl4030_madc->dev,
                        "unable to write sel register 0x%X\n", method->sel + 1);
-               return ret;
+               goto out;
        }
        /* Select averaging for all channels if do_avg is set */
        if (req->do_avg) {
@@ -546,7 +546,7 @@ int twl4030_madc_conversion(struct twl4030_madc_request *req)
                        dev_err(twl4030_madc->dev,
                                "unable to write avg register 0x%X\n",
                                method->avg + 1);
-                       return ret;
+                       goto out;
                }
                ret = twl_i2c_write_u8(TWL4030_MODULE_MADC,
                                       ch_lsb, method->avg);
@@ -554,7 +554,7 @@ int twl4030_madc_conversion(struct twl4030_madc_request *req)
                        dev_err(twl4030_madc->dev,
                                "unable to write sel reg 0x%X\n",
                                method->sel + 1);
-                       return ret;
+                       goto out;
                }
        }
        if (req->type == TWL4030_MADC_IRQ_ONESHOT && req->func_cb != NULL) {
--

1.7.2.2

Signature · 6 lines
Regards and Thanks,
Keerthy
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to Sanjeev Premi
Quoted 11 lines

-----Original Message-----
From: Premi, Sanjeev
Sent: Monday, July 11, 2011 8:51 PM
To: [email protected]
Cc: Premi, Sanjeev; J, KEERTHY; Samuel Ortiz
Subject: [PATCHv2] mfd: twl4030: Fix mismatch in mutex lock-unlock

A mutex is locked on entry into twl4030_madc_conversion(). Immediate return on some error conditions leaves the mutex locked.

Quoted 6 lines

This patch ensures that mutex is always unlocked before leaving the function.

Samuel, Keerthy,

Just wanted to ping both of you on this patch.

~sanjeev

#3 lore raw
In reply to Sanjeev Premi

Hi Premi,

Quoted 6 lines · Sanjeev Premi

A mutex is locked on entry into twl4030_madc_conversion(). Immediate return on some error conditions leaves the mutex locked.

This patch ensures that mutex is always unlocked before leaving the function.

Patch applied, many thanks.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/