Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp4077054rwe; Mon, 17 Apr 2023 07:40:06 -0700 (PDT) X-Google-Smtp-Source: AKy350YJ1fNLU0yN3VN1qTMvQcV3IBeMtDHQLk35YJkkGC1xO03tV+/sdqe0YejmlGN+4fudjeqR X-Received: by 2002:a05:6a20:748d:b0:f0:5c64:265c with SMTP id p13-20020a056a20748d00b000f05c64265cmr896372pzd.16.1681742406522; Mon, 17 Apr 2023 07:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681742406; cv=none; d=google.com; s=arc-20160816; b=p7l0Gq9WBrFaP9189zGNIyUPPs4jYZp8s/Zxt3uVPJ9EluM0B12kRqJydAKYO/NLY4 L7PEBfY4F11SXMgvn3CjR6pWdrhwx3vhRX6k5XQfTbeKr2+OmI0RaQ80v601wA8rnKXs 4cdesAjfJxbYU+F0u3s596Mk6ZpV1zl49hHFKh0mkvi9XkNaMvrSl+L/kgsT1WN49z0f ZJzU0HZQ1s8iAsKXG1serRliLFZMpjieTsMdDg2ltBUOuf8kTZWW7/oAe1uYHgicK/WQ uHPb/kjchKq0QbLRpm+yiraAYaN7WpnqzbCqg57Ool2mwgsKWenwvGF9sIL7SxGQHhWe ekBg== 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 :message-id:date:subject:cc:to:from; bh=V8LC5rsu/82edhf9M5dDufFTq6+GPaNn7FvZ8ZMT5f0=; b=ogzx+iQ00Pi7gU4mofztdfvHL/iLUD8DFs+AVRN4Jv3Jk2UfHfq6FiFoENVfNwuNeP 9bhCe9pQqLOR99x1Bi/adR27+I6jEhIJmgtbhhEsgZD4G4dAB334geSA3NFi0ssJ2RuD 9Im+/FIlAoMTf+6UcHA+DvqBtaTla4QiN0A2eD2o3Bp0qFIyXiWugldedMABRO7GJMxV lDTEsFEGd+yLXsqRUfmy5yhgQHzqRYH2pbGCExVJFYp7fwBd+Uylsmzvt1xySYFMjh17 VrkuPjvUrp0o80A93762jPx14lA0qsZQAQ0HPlt3sIHx4F2Av8ADsaYUCqGwiLmNNXax rZvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j15-20020a654d4f000000b0050c164c8e99si11507750pgt.436.2023.04.17.07.39.54; Mon, 17 Apr 2023 07:40:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230471AbjDQOex (ORCPT + 99 others); Mon, 17 Apr 2023 10:34:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbjDQOen (ORCPT ); Mon, 17 Apr 2023 10:34:43 -0400 Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58B859EE2 for ; Mon, 17 Apr 2023 07:34:37 -0700 (PDT) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.159) with Microsoft SMTP Server (TLS) id 14.3.498.0; Mon, 17 Apr 2023 17:34:35 +0300 Received: from localhost (10.0.253.138) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Mon, 17 Apr 2023 17:34:35 +0300 From: Nikita Zhandarovich To: Alex Deucher CC: Nikita Zhandarovich , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Jerome Glisse , , , , Subject: [PATCH] drm/ttm: fix null-ptr-deref in radeon_ttm_tt_populate() Date: Mon, 17 Apr 2023 07:34:31 -0700 Message-ID: <20230417143431.58858-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.253.138] X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, drm_prime_sg_to_page_addr_arrays() dereferences 'gtt->ttm' without ensuring that 'gtt' (and therefore 'gtt->tmm') is not NULL. Fix this by testing 'gtt' for NULL value before dereferencing. Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: 40f5cf996991 ("drm/radeon: add PRIME support (v2)") Signed-off-by: Nikita Zhandarovich --- drivers/gpu/drm/radeon/radeon_ttm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 1e8e287e113c..33d01c3bdee4 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -553,7 +553,7 @@ static int radeon_ttm_tt_populate(struct ttm_device *bdev, return 0; } - if (slave && ttm->sg) { + if (gtt && slave && ttm->sg) { drm_prime_sg_to_dma_addr_array(ttm->sg, gtt->ttm.dma_address, ttm->num_pages); return 0; -- 2.25.1