From patchwork Mon Mar 29 15:34:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 48868 X-Patchwork-Delegate: benh@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 8D914B80AD for ; Tue, 30 Mar 2010 02:35:01 +1100 (EST) Received: by ozlabs.org (Postfix) id B153EB7CF5; Tue, 30 Mar 2010 02:34:55 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from mgw1.diku.dk (mgw1.diku.dk [130.225.96.91]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mgw1.diku.dk", Issuer "KU Security Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 0C850B7CD5 for ; Tue, 30 Mar 2010 02:34:55 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by mgw1.diku.dk (Postfix) with ESMTP id 6F8C552C328; Mon, 29 Mar 2010 17:34:51 +0200 (CEST) X-Virus-Scanned: amavisd-new at diku.dk Received: from mgw1.diku.dk ([127.0.0.1]) by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pBLP+ZGeTtRy; Mon, 29 Mar 2010 17:34:46 +0200 (CEST) Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140]) by mgw1.diku.dk (Postfix) with ESMTP id CB8DF52C382; Mon, 29 Mar 2010 17:34:46 +0200 (CEST) Received: from ask.diku.dk (ask.diku.dk [130.225.96.225]) by nhugin.diku.dk (Postfix) with ESMTP id 2AAAC6DFB7A; Mon, 29 Mar 2010 17:28:37 +0200 (CEST) Received: by ask.diku.dk (Postfix, from userid 3767) id B301B200B0; Mon, 29 Mar 2010 17:34:46 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by ask.diku.dk (Postfix) with ESMTP id A552E200AF; Mon, 29 Mar 2010 17:34:46 +0200 (CEST) Date: Mon, 29 Mar 2010 17:34:46 +0200 (CEST) From: Julia Lawall To: Benjamin Herrenschmidt , linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 5/12] drivers/macintosh: Add missing unlock Message-ID: MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org From: Julia Lawall 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/) // @r exists@ expression E1; identifier f; @@ f (...) { <+... * spin_lock_irqsave (E1,...); ... when != E1 * return ...; ...+> } // Signed-off-by: Julia Lawall --- drivers/macintosh/macio-adb.c | 1 + drivers/macintosh/smu.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/macintosh/macio-adb.c b/drivers/macintosh/macio-adb.c index 79119f5..bd6da7a 100644 --- a/drivers/macintosh/macio-adb.c +++ b/drivers/macintosh/macio-adb.c @@ -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; } } diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c index f96feeb..28f75cf 100644 --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c @@ -1182,8 +1182,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);