From patchwork Fri Nov 27 17:52:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11936999 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 64364C3E8C5 for ; Fri, 27 Nov 2020 17:56:48 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 16BD62224A for ; Fri, 27 Nov 2020 17:56:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="x8ZN/bim"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="eSYyYpuV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16BD62224A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pr/QDBCLIdlFhSnWur3iOPvneQj9cm8Et2XhBJauZbk=; b=x8ZN/bimZdMKv5k1MA2Uj7SEi ENjrfgamf2+/U/cEDGre4LTi9s6pI+aV6FhAVD+pPk4EUh8qmYeRbqSzuIPiDYNmhoSv8ZwhvkTmO kmYPoT5xGVa9JX74rFHxC1zgURmM5KtLJIAiUjmhuMQR5NLa6Gi+vAajyujvAWtB3ezY/4qKEevpF SM/Mclidm9ohjn5qMx8UeVJhP8YgGLe1fkFPaEoLcylBe1o2lpGKhMNCqM14lnAjuasmdi+L8DLqV wG84/zuvN2hCElFZ5rwtWi5gF6pXtVC8/7yXV1n7HwD2VV+TiNq92u7RJZt/RVgTnnegGbKsTmwat LTa0T3rjQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kihxw-0005ac-62; Fri, 27 Nov 2020 17:55:28 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kihvj-0004eu-Pd for linux-arm-kernel@lists.infradead.org; Fri, 27 Nov 2020 17:53:14 +0000 Received: by mail-pl1-x641.google.com with SMTP id s2so3011661plr.9 for ; Fri, 27 Nov 2020 09:53:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SEMszfaeuUMfImi2qkZXkG9b/+atgWaOE79vRse18HQ=; b=eSYyYpuVToMAOJMzdxtB/W5YpPslDKCRMHpeeEwshv0oxw9TDx6jtOaJspmxtmG2p2 p/JcJtRiX/ZN2k49u5bSziBPqisCfnoDR7diGAQ0viTuBnR9Dp2H4jSJPf+aSRruef37 Q+jRFuStTELa21FJpirQ5yyUzYoTAmKvpNKEeufVwovDWJ3HbYs481PoblVTb+22RY24 S4Rjn9uGNtICzglAHjbPtC2s6093WO4L58GxngwHvNW1zKi06hw1lXrQJa6GtgbsrAYt D0Bmc7fdhYWtVuhiuKgYoWVoqXzcHmcpX7j2oI+fUWFemZx48f7ayRLoA54pEk0JRGKH FVSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SEMszfaeuUMfImi2qkZXkG9b/+atgWaOE79vRse18HQ=; b=tRRLrqHkQ98fBzwLOAjEVDQGdnZXwwbBZQ523O3SxGZ+sur+dThaaWvtjT67Vrsvls lzSEIzQtGdOkc0GLJv9fC662NrkaltFwI/lPlXoXsV8jmj+38DZOoQONUwyYcIuMoL6l RzknTvoocTm7I1rr7NhdIgzaqdZC6I6c8t8GU4no8AUyX3vYwbB06YLIgzZ0F9fVTLrm Cxwm/7WyIwK/kxbayhiWkKBXuKk1n1RK4j81wP2CsMNpyaL7pZAZ8MSewODDEdsVaxDZ h6el02lNWD3wyRh9zuN28AZgNJXneaG7qoSzVN6ojIA0EDcySffxblT/M7V24b6Xv8NE oWUA== X-Gm-Message-State: AOAM531BHIkV4zNrMhQCNeasp7WM97SL7DFMbELpzmGi4Xex/U3zFlxr 7zj53YClp2h6TXtB6TOOAffyiA== X-Google-Smtp-Source: ABdhPJweg0+K3PYxashlkdKyFMrDzdf4hlRLCU+0F6R8xbMsg6QW9P+w9A0yDxTYr00CCAU4UqcdCw== X-Received: by 2002:a17:902:8d82:b029:d8:c5e8:9785 with SMTP id v2-20020a1709028d82b02900d8c5e89785mr7925196plo.5.1606499590077; Fri, 27 Nov 2020 09:53:10 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id t18sm10536724pji.1.2020.11.27.09.53.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2020 09:53:09 -0800 (PST) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 12/15] coresight: tmc-etr: Check if page is valid before dma_map_page() Date: Fri, 27 Nov 2020 10:52:53 -0700 Message-Id: <20201127175256.1092685-13-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201127175256.1092685-1-mathieu.poirier@linaro.org> References: <20201127175256.1092685-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201127_125311_971531_7281A7AB X-CRM114-Status: GOOD ( 13.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Mao Jinlong alloc_pages_node() return should be checked before calling dma_map_page() to make sure that valid page is mapped or else it can lead to aborts as below: Unable to handle kernel paging request at virtual address ffffffc008000000 Mem abort info: ... pc : __dma_inv_area+0x40/0x58 lr : dma_direct_map_page+0xd8/0x1c8 Call trace: __dma_inv_area tmc_pages_alloc tmc_alloc_data_pages tmc_alloc_sg_table tmc_init_etr_sg_table tmc_alloc_etr_buf tmc_enable_etr_sink_sysfs tmc_enable_etr_sink coresight_enable_path coresight_enable enable_source_store dev_attr_store sysfs_kf_write Cc: stable@vger.kernel.org Fixes: 99443ea19e8b ("coresight: Add generic TMC sg table framework") Signed-off-by: Mao Jinlong Signed-off-by: Sai Prakash Ranjan Reviewed-by: Suzuki K Poulose Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index 525f0ecc129c..a31a4d7ae25e 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -217,6 +217,8 @@ static int tmc_pages_alloc(struct tmc_pages *tmc_pages, } else { page = alloc_pages_node(node, GFP_KERNEL | __GFP_ZERO, 0); + if (!page) + goto err; } paddr = dma_map_page(real_dev, page, 0, PAGE_SIZE, dir); if (dma_mapping_error(real_dev, paddr))