From patchwork Tue Dec 1 08:53:38 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: 335119 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp5496754ilb; Tue, 1 Dec 2020 01:18:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrJploKRRLeYrFLafQHKnS/18XTkhvI4DPXFxo3M5KC+BNlDbMg9IPs3EFfsz6uKnUNM3/ X-Received: by 2002:a05:6402:307c:: with SMTP id bs28mr2126011edb.186.1606814304326; Tue, 01 Dec 2020 01:18:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606814304; cv=none; d=google.com; s=arc-20160816; b=g5DZnJuC0pKkM4jGhPDdDChkJZ6mTcreK8ITKrGpVZuFR5844LsbJVibrqtiLZHUJy tffv0JgMZ8dpFb+gEjIRPqTpij4KCYZImXqYsA2FcL1231GB1rDC40dZgJIrARlujjtV zuUWmJ8ugB6oFoqh4Tw7Q/T49Zlti1+D9gTKQF9rhnFmfNTs8NpfFC6YgaZc/sa3sCXw LWIKiUFuTEMoPPenDnLlST0+E4ebXMIyW5UOF2zTtpoQiWGsJ4yk/eD9W3uJK74zViOq o0Ac2G7a82jOrpF1nKsdR81rpSNb98YgHh1m4Y2jM09TkwiMOYNxkBDzwz+Y1F+jrZ3R Ahuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=B6d2pxe+iT9OjZXx/4eMY89xHnrTYhBtn5HyqIE1b1c=; b=HqWOIDKZ+DOgZe0462loNU4nCY6q0ru7bnGdfJCKXN/2HpDmNVXur4E3KhB7mfhel/ 379KCk54xE+Q7k3o2Z6DJ+OupbGQo5ljsoDgNZPAztueJ1viZrRlCal7bBeNMHWETA4M FV1z6vPMkcCJ41tlscjplACfkD1Nln3FbGNWcgj0S5ldxQl9WH8ZyveXjoEuQqh6Uf9u d2z7R/r7tuaLVgNYV03Fv2jhg49KZDrfbtGNPlahb74AAEXcuuM5fANdD1TZm3ooVztg hMb0hxaxcf4ixGdAmprWqPfOxP7qBeXSauIZQ8olEyVeno1j7NTVXfhkuPiaiHwshu8Z +sXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bNenS8X6; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d7si557857ejk.78.2020.12.01.01.18.24; Tue, 01 Dec 2020 01:18:24 -0800 (PST) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bNenS8X6; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388834AbgLAJRA (ORCPT + 14 others); Tue, 1 Dec 2020 04:17:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:50772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389015AbgLAJMh (ORCPT ); Tue, 1 Dec 2020 04:12:37 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 879D6206CA; Tue, 1 Dec 2020 09:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813917; bh=yzmrYridZZHC56CRIQEOUhTE+VoFsyBBdUhnkMxaCBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bNenS8X6RSuy8UwjUm/iUqiZaUxaJKQBSjbv/DM3KyI9e/2vGcbXAqpT+c/HtZXls U6rTR34GV8kSjAScffEGdOQ3G9sMud0NADRNR2vXizT+tCJ833s7420nbaQD8m1tjN xXY0UGf1I57qNoCBjXO4p/s6qIlR2dKoxTY9VhhE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shameer Kolothum , Will Deacon , Sasha Levin Subject: [PATCH 5.9 103/152] iommu: Check return of __iommu_attach_device() Date: Tue, 1 Dec 2020 09:53:38 +0100 Message-Id: <20201201084725.342977874@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084711.707195422@linuxfoundation.org> References: <20201201084711.707195422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Shameer Kolothum [ Upstream commit 77c38c8cf52ef715bfc5cab3d14222d4f3e776e2 ] Currently iommu_create_device_direct_mappings() is called without checking the return of __iommu_attach_device(). This may result in failures in iommu driver if dev attach returns error. Fixes: ce574c27ae27 ("iommu: Move iommu_group_create_direct_mappings() out of iommu_group_add_device()") Signed-off-by: Shameer Kolothum Link: https://lore.kernel.org/r/20201119165846.34180-1-shameerali.kolothum.thodi@huawei.com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- drivers/iommu/iommu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) -- 2.27.0 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 609bd25bf154b..6a0a79e3f5641 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -264,16 +264,18 @@ int iommu_probe_device(struct device *dev) */ iommu_alloc_default_domain(group, dev); - if (group->default_domain) + if (group->default_domain) { ret = __iommu_attach_device(group->default_domain, dev); + if (ret) { + iommu_group_put(group); + goto err_release; + } + } iommu_create_device_direct_mappings(group, dev); iommu_group_put(group); - if (ret) - goto err_release; - if (ops->probe_finalize) ops->probe_finalize(dev);