Skip to contentSkip to conversation

cris: fix locking in pcf8563.c

PATCH New Arnd Bergmann 1 participant 1 message Mar 9, 2011 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 cris: fix locking in pcf8563.c

The ioctl function was incorrectly converted to unlocked_ioctl, this fixes the locking.

---

Quoted 21 lines · Michael Brumlow

I was looking through some code and found an issue in the driver you wrote. The problem can be found in "arch/cris/arch-v10/drivers/pcf8563.c" function "pcf8563_unlocked_ioctl". The function locks a mutex and returns, when it should be locking the locking the mutex, storing the return from the function called and then unlocking the mutex and finally returning the stored value of the function called.

# in its current state.
 343 static long pcf8563_unlocked_ioctl(struct file *filp, unsigned
int cmd, unsigned long arg)
 344 {
 345         int ret;
 346
 347         mutex_lock(&pcf8563_mutex);
 348         return pcf8563_ioctl(filp, cmd, arg);
 349         mutex_unlock(&pcf8563_mutex);
 350
 351         return ret;
 352 }
Quoted 12 lines
# what is suggested.
 343 static long pcf8563_unlocked_ioctl(struct file *filp, unsigned
int cmd, unsigned long arg)
 344 {
 345         int ret;
 346
 347         mutex_lock(&pcf8563_mutex);
 348         ret = pcf8563_ioctl(filp, cmd, arg);
 349         mutex_unlock(&pcf8563_mutex);
 350
 351         return ret;
 352 }

You are right. This problem exists in both arch/cris/arch-v10/drivers/pcf8563.c and arch/cris/arch-v32/drivers/pcf8563.c, and apparently both are my fault.

Arnd
---

arch/cris/arch-v10/drivers/pcf8563.c +1 -1
index ea69fab..1391b73 100644
@@ -345,7 +345,7 @@ static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned
 	int ret;
 
 	mutex_lock(&pcf8563_mutex);
-	return pcf8563_ioctl(filp, cmd, arg);
+	ret = pcf8563_ioctl(filp, cmd, arg);
 	mutex_unlock(&pcf8563_mutex);
 
 	return ret;
arch/cris/arch-v32/drivers/pcf8563.c +1 -1
index b6e4fc0..208594f 100644
@@ -341,7 +341,7 @@ static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned
 	int ret;
 
 	mutex_lock(&pcf8563_mutex);
-	return pcf8563_ioctl(filp, cmd, arg);
+	ret = pcf8563_ioctl(filp, cmd, arg);
 	mutex_unlock(&pcf8563_mutex);
 
 	return ret;