From patchwork Fri Nov 15 09:45:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 3187401 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2BFDE9F39E for ; Fri, 15 Nov 2013 09:45:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9424720896 for ; Fri, 15 Nov 2013 09:45:38 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A6DB820696 for ; Fri, 15 Nov 2013 09:45:37 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VhFxz-0005RG-W3; Fri, 15 Nov 2013 09:45:32 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VhFxx-0002ob-Hm; Fri, 15 Nov 2013 09:45:29 +0000 Received: from mail-bk0-x235.google.com ([2a00:1450:4008:c01::235]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VhFxu-0002o1-0C for linux-arm-kernel@lists.infradead.org; Fri, 15 Nov 2013 09:45:26 +0000 Received: by mail-bk0-f53.google.com with SMTP id na10so1528750bkb.26 for ; Fri, 15 Nov 2013 01:45:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=n4xGLmCuyFQP4+0PMQPUZ5AzzMYgWhiql2pUWflz0pI=; b=stXlY6hyFV4oMQx4zDGEg+gs2+guDqe92su3xFzj25SbtLEp1xcRM2uKMbLa+BwkeU OzPCSeOnqealxg60HvCfpL5WQF3iS1gf3koIrbnoSBGekokO9QoPxz0OOyb3t8PPJuGO 9A353d7oOAqiSl4b83y8SPSr1G2QSTo9/fZewpQG/LVj+QiN/rTQyVxekazrldkm5xrq OHO4TnQkpSqqQd2SDhRzWeT6rBwr93B53sFENd1vhkRa6FdU9A0wIlhj2O54LJYZBZ2M GXqGGgWKK7FfSmmBkNS5sgPvhWfZd4tx/wVaCC46hydBOamXdmoCGGeOk1K87Z1mwcm6 TnVA== MIME-Version: 1.0 X-Received: by 10.205.10.200 with SMTP id pb8mr3991102bkb.16.1384508703587; Fri, 15 Nov 2013 01:45:03 -0800 (PST) Received: by 10.204.74.130 with HTTP; Fri, 15 Nov 2013 01:45:03 -0800 (PST) Date: Fri, 15 Nov 2013 17:45:03 +0800 Message-ID: Subject: [PATCH -next] iommu/arm-smmu: fix potential NULL pointer dereference in arm_smmu_map() From: Wei Yongjun To: will.deacon@arm.com, joro@8bytes.org, grant.likely@linaro.org, rob.herring@calxeda.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131115_044526_232156_D4E35B69 X-CRM114-Status: UNSURE ( 9.80 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.0 (--) Cc: yongjun_wei@trendmicro.com.cn, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wei Yongjun The dereference should be moved below the NULL test. Signed-off-by: Wei Yongjun --- drivers/iommu/arm-smmu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 2349d62..a0cc0a5 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1420,9 +1420,8 @@ static int arm_smmu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int flags) { struct arm_smmu_domain *smmu_domain = domain->priv; - struct arm_smmu_device *smmu = smmu_domain->leaf_smmu; - if (!smmu_domain || !smmu) + if (!smmu_domain || !smmu_domain->leaf_smmu) return -ENODEV; /* Check for silent address truncation up the SMMU chain. */