From patchwork Mon Dec 7 08:58:04 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yang X-Patchwork-Id: 65476 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nB78wBBx014281 for ; Mon, 7 Dec 2009 08:58:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759069AbZLGI6B (ORCPT ); Mon, 7 Dec 2009 03:58:01 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759054AbZLGI6B (ORCPT ); Mon, 7 Dec 2009 03:58:01 -0500 Received: from mga11.intel.com ([192.55.52.93]:26979 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759039AbZLGI6A (ORCPT ); Mon, 7 Dec 2009 03:58:00 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 07 Dec 2009 00:53:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.47,353,1257148800"; d="scan'208";a="520404061" Received: from syang10-desktop.sh.intel.com (HELO syang10-desktop) ([10.239.36.76]) by fmsmga002.fm.intel.com with ESMTP; 07 Dec 2009 00:57:59 -0800 Received: from yasker by syang10-desktop with local (Exim 4.69) (envelope-from ) id 1NHZPx-0001Gq-Gc; Mon, 07 Dec 2009 16:58:05 +0800 From: Sheng Yang To: Avi Kivity , Marcelo Tosatti Cc: kvm@vger.kernel.org, Sheng Yang Subject: [PATCH] KVM: Fix possible circular locking in kvm_vm_ioctl_assign_device() Date: Mon, 7 Dec 2009 16:58:04 +0800 Message-Id: <1260176284-4858-1-git-send-email-sheng@linux.intel.com> X-Mailer: git-send-email 1.6.3.3 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c index fd9c097..f73de63 100644 --- a/virt/kvm/assigned-dev.c +++ b/virt/kvm/assigned-dev.c @@ -508,8 +508,8 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm, struct kvm_assigned_dev_kernel *match; struct pci_dev *dev; - down_read(&kvm->slots_lock); mutex_lock(&kvm->lock); + down_read(&kvm->slots_lock); match = kvm_find_assigned_dev(&kvm->arch.assigned_dev_head, assigned_dev->assigned_dev_id); @@ -573,8 +573,8 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm, } out: - mutex_unlock(&kvm->lock); up_read(&kvm->slots_lock); + mutex_unlock(&kvm->lock); return r; out_list_del: list_del(&match->list); @@ -585,8 +585,8 @@ out_put: pci_dev_put(dev); out_free: kfree(match); - mutex_unlock(&kvm->lock); up_read(&kvm->slots_lock); + mutex_unlock(&kvm->lock); return r; }