powerpc/pmac: Add missing unlocks in error path
authorJulia Lawall <julia@diku.dk>
Mon, 29 Mar 2010 05:34:46 +0000 (05:34 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 7 Apr 2010 08:00:44 +0000 (18:00 +1000)
In some error handling cases the lock is not unlocked.

A simplified version of the semantic patch that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@r exists@
expression E1;
identifier f;
@@

f (...) { <+...
* spin_lock_irqsave (E1,...);
... when != E1
* return ...;
...+> }
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
drivers/macintosh/macio-adb.c
drivers/macintosh/smu.c

index 79119f56e82def706ce517bfdb8e9dcebc1eb3d3..bd6da7a9c55bf77f040de2cb4b5314d163eb3b42 100644 (file)
@@ -155,6 +155,7 @@ static int macio_adb_reset_bus(void)
        while ((in_8(&adb->ctrl.r) & ADB_RST) != 0) {
                if (--timeout == 0) {
                        out_8(&adb->ctrl.r, in_8(&adb->ctrl.r) & ~ADB_RST);
+                       spin_unlock_irqrestore(&macio_lock, flags);
                        return -1;
                }
        }
index 888448cf7f1f1fedf4af2212ca242f06f88d04f7..c9da5c4c167d9ea1dbaa995ceb854acfd6001840 100644 (file)
@@ -1183,8 +1183,10 @@ static ssize_t smu_read_command(struct file *file, struct smu_private *pp,
                return -EOVERFLOW;
        spin_lock_irqsave(&pp->lock, flags);
        if (pp->cmd.status == 1) {
-               if (file->f_flags & O_NONBLOCK)
+               if (file->f_flags & O_NONBLOCK) {
+                       spin_unlock_irqrestore(&pp->lock, flags);
                        return -EAGAIN;
+               }
                add_wait_queue(&pp->wait, &wait);
                for (;;) {
                        set_current_state(TASK_INTERRUPTIBLE);