From patchwork Mon Aug 24 08:30:06 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: 265196 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=-13.7 required=3.0 tests=BAYES_00,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=ham 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 7CEB6C433E3 for ; Mon, 24 Aug 2020 08:36:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4AC4F221E2 for ; Mon, 24 Aug 2020 08:36:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598258197; bh=Tj68wpcq8gwgRKTspOtj86cQXqXyuM2JjWCZZk96Frc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=eyibqS75mlNZXPX1sz8JBgUPuevxzbJ+kQWpy8oume0kQQND0GwU8sGwcrJGooXhV dMBPgoVTLrklzLkGz0ia9BShwY7ze4X2fI8fmR8x/8mTcncLQkrcLO5UGIB7SSPn7K bL6hhTzKRF4siOBjjnlDxM2aKIWU4uyTpD6Fyj3A= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbgHXIgf (ORCPT ); Mon, 24 Aug 2020 04:36:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:49262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726730AbgHXIgd (ORCPT ); Mon, 24 Aug 2020 04:36:33 -0400 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 CDFFF22B3F; Mon, 24 Aug 2020 08:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598258193; bh=Tj68wpcq8gwgRKTspOtj86cQXqXyuM2JjWCZZk96Frc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tAb6bLQ1Ugx0Dx3Bvl4WY+snoCUlXvHvo7ko8DsfYMqlcifvX47TQSO99KLfkxapi O3GXyExjhAUsuPD8yPYTEZglzj6H0H90IjAtOd9giJf8cMmhSKGT47MRtLiH0CTcAq jDJGxzXiSMIsl5dvusD08GqQRLWmgJCFl44hO10s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Rob Herring , Sasha Levin Subject: [PATCH 5.8 108/148] of/address: check for invalid range.cpu_addr Date: Mon, 24 Aug 2020 10:30:06 +0200 Message-Id: <20200824082419.198945010@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200824082413.900489417@linuxfoundation.org> References: <20200824082413.900489417@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: Colin Ian King [ Upstream commit f49c7faf776f16607c948d852a03b04a88c3b583 ] Currently invalid CPU addresses are not being sanity checked resulting in SATA setup failure on a SynQuacer SC2A11 development machine. The original check was removed by and earlier commit, so add a sanity check back in to avoid this regression. Fixes: 7a8b64d17e35 ("of/address: use range parser for of_dma_get_range") Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20200817113208.523805-1-colin.king@canonical.com Signed-off-by: Rob Herring Signed-off-by: Sasha Levin --- drivers/of/address.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/of/address.c b/drivers/of/address.c index 8eea3f6e29a44..340d3051b1ce2 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -980,6 +980,11 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz /* Don't error out as we'd break some existing DTs */ continue; } + if (range.cpu_addr == OF_BAD_ADDR) { + pr_err("translation of DMA address(%llx) to CPU address failed node(%pOF)\n", + range.bus_addr, node); + continue; + } dma_offset = range.cpu_addr - range.bus_addr; /* Take lower and upper limits */