From patchwork Tue Apr 4 10:18:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan Ramabadhran X-Patchwork-Id: 9661225 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3FED7602B9 for ; Tue, 4 Apr 2017 10:24:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3104928307 for ; Tue, 4 Apr 2017 10:24:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25A8D2849D; Tue, 4 Apr 2017 10:24:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0A8728307 for ; Tue, 4 Apr 2017 10:24:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753908AbdDDKXy (ORCPT ); Tue, 4 Apr 2017 06:23:54 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45732 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753827AbdDDKTn (ORCPT ); Tue, 4 Apr 2017 06:19:43 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id CB86961150; Tue, 4 Apr 2017 10:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1491301182; bh=EChKcurmEZsWxbaza5TxOvAKg8y2ujaNW/FLyz13jWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V2Dq4GQJFra5TqQYwEpfOz2iY1n1MLF5qRNsMQeLYGbzBvQzf3c6TQQd9clS4vZUL NO5GszdKWZyWK3S1T6JVH70cDsDXzEjoc25fzDQiWLj6wrBK6y0kr2GvKBRRvS4l/F LY3BZZKpfa1vZyMrA3xou0FB8aUrvGocc0H30FZs= Received: from srichara-linux.qualcomm.com (unknown [202.46.23.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sricharan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4B79460F65; Tue, 4 Apr 2017 10:19:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1491301181; bh=EChKcurmEZsWxbaza5TxOvAKg8y2ujaNW/FLyz13jWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LBS5TmRzSJ1kcaDsqbUS+UWLoI0qvIZ9xK44nOnW+vXF7dA3PiZgo6/EIRK3K4cjD Ur+VdIKwJJEvu+j+kL45fTDoMwI6LqP3i6sTphrbqUghE4+ZPkB1AqM1adiO7IRxso m0ix89Rw3OpzguTqvkQFZusPqFVArFfpGSOzN0HA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4B79460F65 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sricharan@codeaurora.org From: Sricharan R To: robin.murphy@arm.com, will.deacon@arm.com, joro@8bytes.org, lorenzo.pieralisi@arm.com, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, m.szyprowski@samsung.com, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, tn@semihalf.com, hanjun.guo@linaro.org, okaya@codeaurora.org, robh+dt@kernel.org, frowand.list@gmail.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, sudeep.holla@arm.com, rjw@rjwysocki.net, lenb@kernel.org, catalin.marinas@arm.com, arnd@arndb.de, linux-arch@vger.kernel.org, gregkh@linuxfoundation.org Cc: sricharan@codeaurora.org Subject: [PATCH V10 06/12] of: device: Fix overflow of coherent_dma_mask Date: Tue, 4 Apr 2017 15:48:19 +0530 Message-Id: <1491301105-5274-7-git-send-email-sricharan@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1491301105-5274-1-git-send-email-sricharan@codeaurora.org> References: <1489086061-9356-1-git-send-email-sricharan@codeaurora.org> <1491301105-5274-1-git-send-email-sricharan@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Size of the dma-range is calculated as coherent_dma_mask + 1 and passed to arch_setup_dma_ops further. It overflows when the coherent_dma_mask is set for full 64 bits 0xFFFFFFFFFFFFFFFF, resulting in size getting passed as 0 wrongly. Fix this by passsing in max(mask, mask + 1). Note that in this case when the mask is set to full 64bits, we will be passing the mask itself to arch_setup_dma_ops instead of the size. The real fix for this should be to make arch_setup_dma_ops receive the mask and handle it, to be done in the future. Signed-off-by: Sricharan R Reviewed-by: Robin Murphy --- drivers/of/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index c17c19d..c2ae6bb 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -107,7 +107,7 @@ void of_dma_configure(struct device *dev, struct device_node *np) ret = of_dma_get_range(np, &dma_addr, &paddr, &size); if (ret < 0) { dma_addr = offset = 0; - size = dev->coherent_dma_mask + 1; + size = max(dev->coherent_dma_mask, dev->coherent_dma_mask + 1); } else { offset = PFN_DOWN(paddr - dma_addr); dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", offset);