Message ID | 20221206104757.31512-1-arefev@swemel.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2748487wrr; Tue, 6 Dec 2022 02:50:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Rk+PVCkIpwcqZ5UPszadQc6vI1NIeoVuNvLlblmmVCC9DcODM/Ko3NWsOPDxoLu0S94n3 X-Received: by 2002:a17:906:c458:b0:7c0:e23f:17cd with SMTP id ck24-20020a170906c45800b007c0e23f17cdmr9076611ejb.491.1670323823055; Tue, 06 Dec 2022 02:50:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670323823; cv=none; d=google.com; s=arc-20160816; b=DOf0Qgt7+eJO1c0DKl3jRIEe2dJzaEWF84Azfrxy2GDaLqPfeqEXOTjIa2mSAeFQ8u qMdd3pwVylju70XGuVHFXRdENXT74FMaEq32XFo/WtTykGNEJeykLwz4eN4q4T+A/F0E 1C3C0DVuZa/R3/8hJW1fqL92NiKaAXFeMKTs5b0hvPGWalCQ2/US3mIIvkrG8JEPT0dc m7aJN6Hz3fhXL2CBK+d53p2xd5BEu8rtx/+r7VaLE0fsSqe3jvGisUMJh0+xpS/rYas9 iqC3S90xomFG9/hlG5Q2PvI4zrmzCNACj45Ms0dCJMQBE0tvLIinfZu67OcCAk6rqfYE Enng== 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:dkim-signature:from; bh=dyDdQ0ouK6C8bS9bKimyo6WyQoc/XZnFKa1MkRVBOUU=; b=q9MUaNI3YhBW2MInNtCmLkJdnPxaLPn2hNx+iRkDXpC29BHgXMvoAbkNikjlP+1orb F1z5HVU0XyHPqJbQue1VcC/ja6ceODUhRzcjrALGkSrX5zqJ2J/feDvsDvv5qgm+1nj9 H4BtcwWt9QkiUrEz8fEu5gzWoL3+mlFeLs6YqnmR3J3CMbx9nBD1z3u38hK+acKKkhOW 2z1KByhedrXXNwKlzmUsQ6Nl+jbkbOo+1ZTIGfJzaeOOPDT8I2BhjL13zYxklXav3onE kMbGhc89WzV/f7IQMLulmk+5dlSXzMMkc8tFaq0UE5Pv9tJgc2b0kiaE3Jg1uHIeSP7S Dp5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=eUZgBGct; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j19-20020a05640211d300b0046aaeca7d05si2038374edw.399.2022.12.06.02.50.00; Tue, 06 Dec 2022 02:50:23 -0800 (PST) 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; dkim=pass header.i=@swemel.ru header.s=mail header.b=eUZgBGct; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234169AbiLFKsE (ORCPT <rfc822;jaysivo@gmail.com> + 99 others); Tue, 6 Dec 2022 05:48:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233785AbiLFKsC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 6 Dec 2022 05:48:02 -0500 Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64A11225 for <linux-kernel@vger.kernel.org>; Tue, 6 Dec 2022 02:48:00 -0800 (PST) From: Denis Arefev <arefev@swemel.ru> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1670323677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=dyDdQ0ouK6C8bS9bKimyo6WyQoc/XZnFKa1MkRVBOUU=; b=eUZgBGctez7/faDwGHUnXo0cKQutXkFVBBoyVX6M9Qvwybd7AhC7TAbCcDg+bdqNrSYtVs 6Ca9APE+/edoMT9CpKngwaL8dd6GjVYFKBuy35NnW30qm/U1zrLoFJH7KURuQ8xidTAmeE UKmkFX0dnTNI9TPEUU/JCFrrlOgqNhA= To: Harry Wentland <harry.wentland@amd.com> Cc: Leo Li <sunpeng.li@amd.com>, Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>, Alex Deucher <alexander.deucher@amd.com>, =?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>, "Pan, Xinhui" <Xinhui.Pan@amd.com>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Aurabindo Pillai <aurabindo.pillai@amd.com>, Roman Li <roman.li@amd.com>, =?utf-8?q?Michel_D=C3=A4nzer?= <mdaenzer@redhat.com>, Fangzhi Zuo <Jerry.Zuo@amd.com>, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, trufanov@swemel.ru, vfh@swemel.ru Subject: [PATCH] drm/amd/display: Added pointer check Date: Tue, 6 Dec 2022 13:47:57 +0300 Message-Id: <20221206104757.31512-1-arefev@swemel.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751461472647224281?= X-GMAIL-MSGID: =?utf-8?q?1751461472647224281?= |
Series |
drm/amd/display: Added pointer check
|
|
Commit Message
Denis Arefev
Dec. 6, 2022, 10:47 a.m. UTC
Return value of a function 'dc_create_state' is
dereferenced at amdgpu_dm.c:2027 without checking for null
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Denis Arefev <arefev@swemel.ru>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
Am 06.12.22 um 11:47 schrieb Denis Arefev: > Return value of a function 'dc_create_state' is > dereferenced at amdgpu_dm.c:2027 without checking for null > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Signed-off-by: Denis Arefev <arefev@swemel.ru> > --- > drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > index 0f7749e9424d..529483997154 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > @@ -1960,7 +1960,9 @@ static int dm_resume(void *handle) > dc_release_state(dm_state->context); > dm_state->context = dc_create_state(dm->dc); > /* TODO: Remove dc_state->dccg, use dc->dccg directly. */ > - dc_resource_state_construct(dm->dc, dm_state->context); > + if (dm_state->context) { > + dc_resource_state_construct(dm->dc, dm_state->context); > + } Single line statements shouldn't have an {} around them. Apart from that I think error handling when dm_state->context can't be created would be more appropriate, but that's something our display team needs to look at. Regards, Christian. > > /* Before powering on DC we need to re-initialize DMUB. */ > r = dm_dmub_hw_init(adev);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 0f7749e9424d..529483997154 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -1960,7 +1960,9 @@ static int dm_resume(void *handle) dc_release_state(dm_state->context); dm_state->context = dc_create_state(dm->dc); /* TODO: Remove dc_state->dccg, use dc->dccg directly. */ - dc_resource_state_construct(dm->dc, dm_state->context); + if (dm_state->context) { + dc_resource_state_construct(dm->dc, dm_state->context); + } /* Before powering on DC we need to re-initialize DMUB. */ r = dm_dmub_hw_init(adev);