Skip to contentSkip to conversation

Staging: rtl8188eu: fix double unlock

PATCH RESEND In review Matteo Semenzato 3 participants 7 messages Mar 7, 2015 – Mar 9, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 Staging: rtl8188eu: fix double unlock

From: Matteo Semenzato <[email protected]>

The rtw_cmd_thread semaphore was being unlocked twice.

---
 drivers/staging/rtl8188eu/core/rtw_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8188eu/core/rtw_cmd.c +1 -1
index 4b43462..43a8515 100644
@@ -173,7 +173,7 @@ int rtw_cmd_thread(void *context)
 	allow_signal(SIGTERM);
 
 	pcmdpriv->cmdthd_running = true;
-	up(&pcmdpriv->terminate_cmdthread_sema);
+	down(&pcmdpriv->terminate_cmdthread_sema);
 
 	RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n"));
 
Signature · 1 line
2.3.1
#1 lore raw
Quoted 14 lines · Matteo Semenzato

From: Matteo Semenzato <[email protected]>

The rtw_cmd_thread semaphore was being unlocked twice.

---
  drivers/staging/rtl8188eu/core/rtw_cmd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8188eu/core/rtw_cmd.c +0 -0
index 4b43462..43a8515 100644

drivers/staging/rtl8188eu/core/rtw_cmd.c int rtw_cmd_thread(void *context) · line 178

Quoted 7 lines
drivers/staging/rtl8188eu/core/rtw_cmd.c +1 -1
@@ -173,7 +173,7 @@ int rtw_cmd_thread(void *context)
  	allow_signal(SIGTERM);
 
  	pcmdpriv->cmdthd_running = true;
-	up(&pcmdpriv->terminate_cmdthread_sema);
+	down(&pcmdpriv->terminate_cmdthread_sema);
 
  	RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n"));

I get nervous when I see patch 2/2 immediately resent as a single patch. What is going on?

Have you actually tested this patch, or did you find this with some static checker?

Larry

#2 lore raw

Il giorno sab, 07/03/2015 alle 11.28 -0600, Larry Finger ha scritto:

Quoted 3 lines

Have you actually tested this patch, or did you find this with some static checker?

Larry

The double unlock was found using smatch.

#3 lore raw
Quoted 5 lines · Matteo Semenzato

Il giorno sab, 07/03/2015 alle 11.28 -0600, Larry Finger ha scritto:

Quoted 3 lines

Have you actually tested this patch, or did you find this with some static checker?

Larry

The double unlock was found using smatch.

Are you really willing to test changes in locking based on a static checker? I would not be so quick.

By the way, my reading of the documentation is that up releases the lock whereas down sets it. Thus, I think your patch introduces a bug rather than fix one. I agree that there is a mismatch, but I do not think your patch fixes anything.

Until this is actually tested on running code, NACK.

Larry

#4 lore raw
In reply to Matteo Semenzato

Why is it a RESEND?

RESEND is a bit rude because it implies that we messed up by ignoring your first email so you're sending us the exact same thing again. Sometimes rudeness is valid if people are ignoring good patches but you send the first email 4 minutes before sending the second email.

Quoted 1 line · Matteo Semenzato

From: Matteo Semenzato <[email protected]>

No need for this, we can get it from your email.

Quoted 2 lines

The rtw_cmd_thread semaphore was being unlocked twice.

This patch is probably correct, but it's a bit risky without testing or further analysis. Please explain how you verified that it won't cause a deadlock.

regards,
dan carpenter

#5 lore raw

Il giorno lun, 09/03/2015 alle 12.16 +0300, Dan Carpenter ha scritto:

Quoted 6 lines

Why is it a RESEND?

RESEND is a bit rude because it implies that we messed up by ignoring your first email so you're sending us the exact same thing again. Sometimes rudeness is valid if people are ignoring good patches but you send the first email 4 minutes before sending the second email.

This patch is a RESEND because i forgot to remove PATCH 2/2 from the subject.

Quoted 11 lines · Matteo Semenzato
Quoted 1 line

From: Matteo Semenzato <[email protected]>

No need for this, we can get it from your email.

Quoted 2 lines

The rtw_cmd_thread semaphore was being unlocked twice.

This patch is probably correct, but it's a bit risky without testing or further analysis. Please explain how you verified that it won't cause a deadlock.

This patch is wrong because it tries to call down on a semaphore that is initialized to 0 and the semaphore is not unlocked anywhere else.

#6 lore raw
Quoted 14 lines · Matteo Semenzato

Il giorno lun, 09/03/2015 alle 12.16 +0300, Dan Carpenter ha scritto:

Quoted 6 lines

Why is it a RESEND?

RESEND is a bit rude because it implies that we messed up by ignoring your first email so you're sending us the exact same thing again. Sometimes rudeness is valid if people are ignoring good patches but you send the first email 4 minutes before sending the second email.

This patch is a RESEND because i forgot to remove PATCH 2/2 from the subject.

Quoted 6 lines · Matteo Semenzato
Quoted 1 line

From: Matteo Semenzato <[email protected]>

No need for this, we can get it from your email.

Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

The rtw_cmd_thread semaphore was being unlocked twice.

This patch is probably correct, but it's a bit risky without testing or further analysis. Please explain how you verified that it won't cause a deadlock.

This patch is wrong because it tries to call down on a semaphore that is initialized to 0 and the semaphore is not unlocked anywhere else.

Yep. Just remove the locking and use kthread_stop() in rtw_stop_drv_threads().

regards,
dan carpenter