From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756720Ab0EZP4I (ORCPT ); Wed, 26 May 2010 11:56:08 -0400 Received: from mgw2.diku.dk ([130.225.96.92]:40711 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755439Ab0EZP4E (ORCPT ); Wed, 26 May 2010 11:56:04 -0400 Date: Wed, 26 May 2010 17:55:59 +0200 (CEST) From: Julia Lawall To: Joerg Roedel , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 6/17] arch/x86/kernel: Add missing spin_unlock Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julia Lawall Add a spin_unlock missing on the error path. The locks and unlocks are balanced in other functions, so it seems that the same should be the case here. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression E1; @@ * spin_lock(E1,...); <+... when != E1 if (...) { ... when != E1 * return ...; } ...+> * spin_unlock(E1,...); // Signed-off-by: Julia Lawall --- arch/x86/kernel/amd_iommu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c index fa5a147..b98e1cd 100644 --- a/arch/x86/kernel/amd_iommu.c +++ b/arch/x86/kernel/amd_iommu.c @@ -1499,12 +1499,16 @@ static int __attach_device(struct device *dev, /* Some sanity checks */ if (alias_data->domain != NULL && - alias_data->domain != domain) + alias_data->domain != domain) { + spin_unlock(&domain->lock); return -EBUSY; + } if (dev_data->domain != NULL && - dev_data->domain != domain) + dev_data->domain != domain) { + spin_unlock(&domain->lock); return -EBUSY; + } /* Do real assignment */ if (dev_data->alias != dev) {