Skip to contentSkip to conversation

coresight-etm: unlock on error paths in mode_store()

PATCH In review Dan Carpenter 2 participants 2 messages Nov 12, 2014 – Nov 13, 2014 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 coresight-etm: unlock on error paths in mode_store()

There are some missing unlocks on the error paths.

Fixes a939fc5a71ad ('coresight-etm: add CoreSight ETM/PTM driver')

---
I don't have a cross compiler set up so I haven't compiled this. But I think it doesn't have any typos. :)

drivers/coresight/coresight-etm3x.c +8 -2
index d9e3ed6..369cac0 100644
@@ -573,7 +573,8 @@ static ssize_t mode_store(struct device *dev,
 	if (drvdata->mode & ETM_MODE_STALL) {
 		if (!(drvdata->etmccr & ETMCCR_FIFOFULL)) {
 			dev_warn(drvdata->dev, "stall mode not supported\n");
-			return -EINVAL;
+			ret = -EINVAL;
+			goto err_unlock;
 		}
 		drvdata->ctrl |= ETMCR_STALL_MODE;
 	 } else
@@ -582,7 +583,8 @@ static ssize_t mode_store(struct device *dev,
 	if (drvdata->mode & ETM_MODE_TIMESTAMP) {
 		if (!(drvdata->etmccer & ETMCCER_TIMESTAMP)) {
 			dev_warn(drvdata->dev, "timestamp not supported\n");
-			return -EINVAL;
+			ret = -EINVAL;
+			goto err_unlock;
 		}
 		drvdata->ctrl |= ETMCR_TIMESTAMP_EN;
 	} else
@@ -595,6 +597,10 @@ static ssize_t mode_store(struct device *dev,
 	spin_unlock(&drvdata->spinlock);
 
 	return size;
+
+err_unlock:
+	spin_unlock(&drvdata->spinlock);
+	return ret;
 }
 static DEVICE_ATTR_RW(mode);
 
#1 lore raw
Quoted 33 lines · Dan Carpenter

There are some missing unlocks on the error paths.

Fixes a939fc5a71ad ('coresight-etm: add CoreSight ETM/PTM driver')

---
I don't have a cross compiler set up so I haven't compiled this. But I think it doesn't have any typos. :)

drivers/coresight/coresight-etm3x.c +4 -2
index d9e3ed6..369cac0 100644
@@ -573,7 +573,8 @@ static ssize_t mode_store(struct device *dev,
        if (drvdata->mode & ETM_MODE_STALL) {
                if (!(drvdata->etmccr & ETMCCR_FIFOFULL)) {
                        dev_warn(drvdata->dev, "stall mode not supported\n");
-                       return -EINVAL;
+                       ret = -EINVAL;
+                       goto err_unlock;
                }
                drvdata->ctrl |= ETMCR_STALL_MODE;
         } else
@@ -582,7 +583,8 @@ static ssize_t mode_store(struct device *dev,
        if (drvdata->mode & ETM_MODE_TIMESTAMP) {
                if (!(drvdata->etmccer & ETMCCER_TIMESTAMP)) {
                        dev_warn(drvdata->dev, "timestamp not supported\n");
-                       return -EINVAL;
+                       ret = -EINVAL;
+                       goto err_unlock;
                }
                drvdata->ctrl |= ETMCR_TIMESTAMP_EN;
        } else

drivers/coresight/coresight-etm3x.c static ssize_t mode_store(struct device *dev, · line 606

Quoted 10 lines
drivers/coresight/coresight-etm3x.c +4 -0
@@ -595,6 +597,10 @@ static ssize_t mode_store(struct device *dev,
        spin_unlock(&drvdata->spinlock);
 
        return size;
+
+err_unlock:
+       spin_unlock(&drvdata->spinlock);
+       return ret;
 }
 static DEVICE_ATTR_RW(mode);
 

Applied - thanks