Skip to content

Commit

Permalink
powerpc/pmac: Add missing unlocks in error path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Julia Lawall authored and Benjamin Herrenschmidt committed Apr 7, 2010
1 parent f6d8c8b commit 86e4754
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions drivers/macintosh/macio-adb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
4 changes: 3 additions & 1 deletion drivers/macintosh/smu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 86e4754

Please sign in to comment.