Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3706362pxb; Mon, 24 Jan 2022 15:55:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxK/Vvg+NTGzvjrXRK0W0uT/W9q/9uP1WKuccTFlCzui8E7M6c8pcRxgbs1vDNQx9F3/cfZ X-Received: by 2002:a63:6f87:: with SMTP id k129mr13532763pgc.248.1643068469756; Mon, 24 Jan 2022 15:54:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643068469; cv=none; d=google.com; s=arc-20160816; b=VSyY8d0cZe+pPFgSSYxwv7/YkagqD8Cwy7uI3U86ZNx7yyyyEyAGc/e7BTzUkn67sT jTymxMKdWtV1IDP+xcHS1Qqpnntwja5l4EVV3s2sXVluZohKcM098jkfItOGEmKjw/a/ sOoj3AdTmx6yFqtJkGsCgE62X2XNYmKtIYBffS8yboI4XVya8wBjMvUn39IlfRrKgAsw Lv6gXmeqzpEIulcJ++8DNX8PxazpcTukew/LKVn0e9dXyDUF/tDzNLOo3yHmytRjR0FE jXqDu4yFb3zHrkQfnmF0/zhQD6DdgbLck8d/oOAyQ/qZDrJTC/9cv6/SQ1xB+hh6XUEP zvtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H4S0hoSgv/+PdW6RbU4zL+mAYkPf0zT8AAlMWMSn5os=; b=CZ37SYlWm6jXmNx6j4VRKeugwc1ZJxfypwYPwd7TIMuNoQvy0Z158gF79ZyEtMMKLA jodQ0LoiqFFOmxHuTujhyIPRYssMtEEAv7iXOkw1AmhEuEcKSw+3awpLSZpv+deXzBK3 QlaEf9zbhIFuCIYK3uQ8v5tPow3DNAXRS0U6BrWh6A8DC62N83aV17XPN7qPDMr+eRh2 S7hc5rXTKGUNIVQTvvUDk+b1z1GziLR/WeGT5bT2TfyJjZoW2AG1p+WLPp7yIuLvfktL cdvl7jzZg8fVTxeiUtJjS+tQAI0SD7pcFfWvE45ombbN8It3sDrNm2q2XIRLUhLSopoK rO/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ScHgq0ui; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si13222178pgc.510.2022.01.24.15.54.17; Mon, 24 Jan 2022 15:54:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ScHgq0ui; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2364464AbiAXXsP (ORCPT + 99 others); Mon, 24 Jan 2022 18:48:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382994AbiAXWxz (ORCPT ); Mon, 24 Jan 2022 17:53:55 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 605E1C055AB2; Mon, 24 Jan 2022 13:08:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F39DE611C8; Mon, 24 Jan 2022 21:08:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC52BC340E5; Mon, 24 Jan 2022 21:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058522; bh=AGVcsL5Qg8R5tXC51h+0QVmhQuDGSTsNbuHUgh2FqcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ScHgq0uihkKx5Pqo31KSkV3GM7xQ9wagW+SLXfYPqcyl/EWNm3JkuDKaXzMqMqo+3 PeKpUQeYCSrznEeT64oIsZh7TSY5Yc6gWnTEI7+9KA1VkAq7XLEy14bCcnP501GyGw C8OgADb9feBhwFh8T5qcekNCJzeymQSuLvvVXXlU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thierry Reding , Mikko Perttunen , dri-devel@lists.freedesktop.org, Robin Murphy , Christoph Hellwig , Thierry Reding , Sasha Levin Subject: [PATCH 5.16 0299/1039] drm/tegra: vic: Fix DMA API misuse Date: Mon, 24 Jan 2022 19:34:48 +0100 Message-Id: <20220124184135.352393486@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Robin Murphy [ Upstream commit 5566174cb10a5167d59b0793871cab7990b149b8 ] Upon failure, dma_alloc_coherent() returns NULL. If that does happen, passing some uninitialised stack contents to dma_mapping_error() - which belongs to a different API in the first place - has precious little chance of detecting it. Also include the correct header, because the fragile transitive inclusion currently providing it is going to break soon. Fixes: 20e7dce255e9 ("drm/tegra: Remove memory allocation from Falcon library") CC: Thierry Reding CC: Mikko Perttunen CC: dri-devel@lists.freedesktop.org Signed-off-by: Robin Murphy Reviewed-by: Christoph Hellwig Signed-off-by: Thierry Reding Signed-off-by: Sasha Levin --- drivers/gpu/drm/tegra/vic.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c index c02010ff2b7f2..da4af53719917 100644 --- a/drivers/gpu/drm/tegra/vic.c +++ b/drivers/gpu/drm/tegra/vic.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -232,10 +233,8 @@ static int vic_load_firmware(struct vic *vic) if (!client->group) { virt = dma_alloc_coherent(vic->dev, size, &iova, GFP_KERNEL); - - err = dma_mapping_error(vic->dev, iova); - if (err < 0) - return err; + if (!virt) + return -ENOMEM; } else { virt = tegra_drm_alloc(tegra, size, &iova); } -- 2.34.1