From patchwork Tue Jan 28 14:04:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 232555 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21CA6C2D0DB for ; Tue, 28 Jan 2020 14:36:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E049E20702 for ; Tue, 28 Jan 2020 14:36:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580222195; bh=82oBk3V6XH8DMTqOHW/rTRzWb1gZ1spYcwkITJN6/pI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=G86I752ec39NWugyt6ng6NDmQa5RTAf/voLLqO4HmIJee/xKlzh/Ttlr1NLO7iX9o y4JGCKNaKmLkJO+Ip/y2pOjfusNcEnNMvHvHTEkGhk5Si4q3I7yNgJ4H2pcNMolGmc 4CumYzPSo2W73mI3iI8W0uv9NrYhZqlRo85QGKG0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731325AbgA1OVf (ORCPT ); Tue, 28 Jan 2020 09:21:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:46928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731311AbgA1OVe (ORCPT ); Tue, 28 Jan 2020 09:21:34 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2471424686; Tue, 28 Jan 2020 14:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221293; bh=82oBk3V6XH8DMTqOHW/rTRzWb1gZ1spYcwkITJN6/pI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wHrC2akmTIxLz98Hpn75zmkdFWVvdEyaby7hYEVAWZkY/aobzTlKQn44nMwcRAstK c+3uJERr+1YS6g7iEUSl1k27DIorNBpCBDMnDGVGSzAdyPz0zxIVxvnFZX268k0u6j 6rv1JJIFrwxyuhN24MbI/gmTe2wc0NT5mnbkH6ug= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lu Baolu , Joerg Roedel , Sasha Levin Subject: [PATCH 4.9 149/271] iommu: Use right function to get group for device Date: Tue, 28 Jan 2020 15:04:58 +0100 Message-Id: <20200128135903.643607538@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Lu Baolu [ Upstream commit 57274ea25736496ee019a5c40479855b21888839 ] The iommu_group_get_for_dev() will allocate a group for a device if it isn't in any group. This isn't the use case in iommu_request_dm_for_dev(). Let's use iommu_group_get() instead. Fixes: d290f1e70d85a ("iommu: Introduce iommu_request_dm_for_dev()") Signed-off-by: Lu Baolu Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 71b89e47e9521..dbcc13efaf3c8 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1582,9 +1582,9 @@ int iommu_request_dm_for_dev(struct device *dev) int ret; /* Device must already be in a group before calling this function */ - group = iommu_group_get_for_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); + group = iommu_group_get(dev); + if (!group) + return -EINVAL; mutex_lock(&group->mutex);