From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752505AbdHHUom (ORCPT ); Tue, 8 Aug 2017 16:44:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33432 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752437AbdHHUol (ORCPT ); Tue, 8 Aug 2017 16:44:41 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BF9DE23D07 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=eric.auger@redhat.com From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, linux-kernel@vger.kernel.org, alex.williamson@redhat.com Subject: [PATCH] vfio: fix noiommu vfio_iommu_group_get reference count Date: Tue, 8 Aug 2017 22:44:28 +0200 Message-Id: <1502225068-9699-1-git-send-email-eric.auger@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 08 Aug 2017 20:44:41 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In vfio_iommu_group_get() we want to increase the reference count of the iommu group. In noiommu case, the group does not exist and is allocated. iommu_group_add_device() increases the group ref count. However we then call iommu_group_put() which decrements it. This leads to a "refcount_t: underflow WARN_ON". Signed-off-by: Eric Auger --- drivers/vfio/vfio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 330d505..fd8d691 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -138,7 +138,6 @@ struct iommu_group *vfio_iommu_group_get(struct device *dev) iommu_group_set_name(group, "vfio-noiommu"); iommu_group_set_iommudata(group, &noiommu, NULL); ret = iommu_group_add_device(group, dev); - iommu_group_put(group); if (ret) return NULL; -- 2.5.5