mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 4/17] drivers/isdn/hardware/mISDN: Add missing spin_unlock
@ 2010-05-26 15:55 Julia Lawall
  2010-05-29  7:19 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2010-05-26 15:55 UTC (permalink / raw)
  To: Karsten Keil, netdev, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

Add a spin_unlock missing on the error path.  The return value of write_reg
seems to be completely ignored, so it seems that the lock should be
released in every case.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression E1;
@@

* spin_lock(E1,...);
  <+... when != E1
  if (...) {
    ... when != E1
*   return ...;
  }
  ...+>
* spin_unlock(E1,...);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/isdn/hardware/mISDN/hfcsusb.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.c b/drivers/isdn/hardware/mISDN/hfcsusb.c
index b3b7e28..8700474 100644
--- a/drivers/isdn/hardware/mISDN/hfcsusb.c
+++ b/drivers/isdn/hardware/mISDN/hfcsusb.c
@@ -97,8 +97,10 @@ static int write_reg(struct hfcsusb *hw, __u8 reg, __u8 val)
 			hw->name, __func__, reg, val);
 
 	spin_lock(&hw->ctrl_lock);
-	if (hw->ctrl_cnt >= HFC_CTRL_BUFSIZE)
+	if (hw->ctrl_cnt >= HFC_CTRL_BUFSIZE) {
+		spin_unlock(&hw->ctrl_lock);
 		return 1;
+	}
 	buf = &hw->ctrl_buff[hw->ctrl_in_idx];
 	buf->hfcs_reg = reg;
 	buf->reg_val = val;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 4/17] drivers/isdn/hardware/mISDN: Add missing spin_unlock
  2010-05-26 15:55 [PATCH 4/17] drivers/isdn/hardware/mISDN: Add missing spin_unlock Julia Lawall
@ 2010-05-29  7:19 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-05-29  7:19 UTC (permalink / raw)
  To: julia; +Cc: isdn, netdev, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>
Date: Wed, 26 May 2010 17:55:10 +0200 (CEST)

> From: Julia Lawall <julia@diku.dk>
> 
> Add a spin_unlock missing on the error path.  The return value of write_reg
> seems to be completely ignored, so it seems that the lock should be
> released in every case.
> 
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
 ...
> Signed-off-by: Julia Lawall <julia@diku.dk>

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-29  7:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-26 15:55 [PATCH 4/17] drivers/isdn/hardware/mISDN: Add missing spin_unlock Julia Lawall
2010-05-29  7:19 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®