From patchwork Thu Oct 15 15:04:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 55035 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lf0-f70.google.com (mail-lf0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 595482301F for ; Thu, 15 Oct 2015 15:05:02 +0000 (UTC) Received: by lffv3 with SMTP id v3sf3810276lff.1 for ; Thu, 15 Oct 2015 08:05:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=uVws4abKnu+e5d/kiD35SOF8TXNGY2mounvSX1bGGQE=; b=fzpNhcPvzZlY365i9cVTMPR5mpnsYO1h7+eL7vh4J8wHXTaPPYOVP5LdBXW+ynZ/Og wcjjIZu2D0aRunQSedDwP6rbgMCzXgNOGUUr0T1vUO+shyiivyCRfuoQAiX/U5ILkAJ3 zcpJyW/xSH+4RKGFHgNh/ZbhLpnqAFak3ej1uAenHD1ZbqHl5bvThaVrzLpLCehPGIMx 8MH0MrWe8g5IiJ1TTdorrEZK9SHKAzm+J7qv1wSaK+cTW9x1WAEQknBopIXQXT4DhCbF HuUdZlm9hFL56R5qzz1x29xAt6EZ+ii2+ScQciWM+cSIZN8ef+llKQll1rvkJEL4V1pi xSKA== X-Gm-Message-State: ALoCoQkzBJ+kcfos+GXrXDTAIScsn5EvYFJWVMJfkjsEhJK8XVUTLg6mPYf+C7NfSbXyiYabcsXq X-Received: by 10.112.16.229 with SMTP id j5mr2301168lbd.6.1444921501216; Thu, 15 Oct 2015 08:05:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.87.139 with SMTP id l133ls167008lfb.34.gmail; Thu, 15 Oct 2015 08:05:00 -0700 (PDT) X-Received: by 10.112.209.71 with SMTP id mk7mr4877006lbc.46.1444921500882; Thu, 15 Oct 2015 08:05:00 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id 198si9412577lfz.119.2015.10.15.08.04.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Oct 2015 08:04:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbbpp2 with SMTP id pp2so43259589lbb.0 for ; Thu, 15 Oct 2015 08:04:59 -0700 (PDT) X-Received: by 10.112.199.137 with SMTP id jk9mr4911109lbc.86.1444921499157; Thu, 15 Oct 2015 08:04:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp688387lbq; Thu, 15 Oct 2015 08:04:58 -0700 (PDT) X-Received: by 10.68.69.108 with SMTP id d12mr10309464pbu.137.1444921498039; Thu, 15 Oct 2015 08:04:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pa7si22182105pac.231.2015.10.15.08.04.56; Thu, 15 Oct 2015 08:04:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752031AbbJOPEz (ORCPT + 1 other); Thu, 15 Oct 2015 11:04:55 -0400 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]:60887 "EHLO cam-admin0.cambridge.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751302AbbJOPEz (ORCPT ); Thu, 15 Oct 2015 11:04:55 -0400 Received: from edgewater-inn.cambridge.arm.com (edgewater-inn.cambridge.arm.com [10.1.203.122]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id t9FF4MWr012671; Thu, 15 Oct 2015 16:04:22 +0100 (BST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id DEB6E1AE3448; Thu, 15 Oct 2015 16:04:25 +0100 (BST) From: Will Deacon To: iommu@lists.linux-foundation.org Cc: linux-arm-kernel@lists.infradead.org, jroedel@suse.de, marc.zyngier@arm.com, robin.murphy@arm.com, tchalamarla@caviumnetworks.com, fabio.estevam@freescale.com, Will Deacon , Subject: [PATCH 4/6] iommu/arm-smmu: fix error checking for ASID and VMID allocation Date: Thu, 15 Oct 2015 16:04:22 +0100 Message-Id: <1444921464-14895-5-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1444921464-14895-1-git-send-email-will.deacon@arm.com> References: <1444921464-14895-1-git-send-email-will.deacon@arm.com> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.deacon@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The bitmap allocator returns an int, which is one of the standard negative values on failure. Rather than assigning this straight to a u16 (like we do for the ASID and VMID callers), which means that we won't detect failure correctly, use an int for the purposes of error checking. Cc: Signed-off-by: Will Deacon --- drivers/iommu/arm-smmu-v3.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 637014ab8965..970d78dcac53 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -1419,7 +1419,7 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain, struct io_pgtable_cfg *pgtbl_cfg) { int ret; - u16 asid; + int asid; struct arm_smmu_device *smmu = smmu_domain->smmu; struct arm_smmu_s1_cfg *cfg = &smmu_domain->s1_cfg; @@ -1431,10 +1431,11 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain, &cfg->cdptr_dma, GFP_KERNEL); if (!cfg->cdptr) { dev_warn(smmu->dev, "failed to allocate context descriptor\n"); + ret = -ENOMEM; goto out_free_asid; } - cfg->cd.asid = asid; + cfg->cd.asid = (u16)asid; cfg->cd.ttbr = pgtbl_cfg->arm_lpae_s1_cfg.ttbr[0]; cfg->cd.tcr = pgtbl_cfg->arm_lpae_s1_cfg.tcr; cfg->cd.mair = pgtbl_cfg->arm_lpae_s1_cfg.mair[0]; @@ -1448,7 +1449,7 @@ out_free_asid: static int arm_smmu_domain_finalise_s2(struct arm_smmu_domain *smmu_domain, struct io_pgtable_cfg *pgtbl_cfg) { - u16 vmid; + int vmid; struct arm_smmu_device *smmu = smmu_domain->smmu; struct arm_smmu_s2_cfg *cfg = &smmu_domain->s2_cfg; @@ -1456,7 +1457,7 @@ static int arm_smmu_domain_finalise_s2(struct arm_smmu_domain *smmu_domain, if (IS_ERR_VALUE(vmid)) return vmid; - cfg->vmid = vmid; + cfg->vmid = (u16)vmid; cfg->vttbr = pgtbl_cfg->arm_lpae_s2_cfg.vttbr; cfg->vtcr = pgtbl_cfg->arm_lpae_s2_cfg.vtcr; return 0;