Message ID | 20221111071446.22951-1-arefev@swemel.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp594882wru; Thu, 10 Nov 2022 23:30:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf4luVwGNLuzJvHVBDfFfGN5DHoLGLhdPkjYV7ak3RPOy1jHtPyN7vTsiHYgXOoyhwshflgh X-Received: by 2002:a05:6402:3222:b0:464:718c:b266 with SMTP id g34-20020a056402322200b00464718cb266mr341197eda.320.1668151838383; Thu, 10 Nov 2022 23:30:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668151838; cv=none; d=google.com; s=arc-20160816; b=vCbK1dmcj2NGfvy+WE7eK3oPcRG7u3noFulEWCw/YZR1dluIpoF6RAZiyT5zjLQgl/ OWi9cPbM7O8oVh5QtXIV1tDoih5v3yKHQBYPZzWlrmbIR5e3ama80zAdumZSpLGPiJBG fAieQcvIRV5Z+99sRU1/i4E1w6C4lHUoCDdCTL3L6spFxvgbmVA1rwfJrBiGzh6QgMUg KkwSWe0vECCg6Xn8Ex91cHRQWTkhQyYQ+8iqPP5AnGw5d4ISXLKJdT/Se39I8RugqWgw NmkK03Z95E/tMv0h2gEe7Tn5G4iRafIeewviNfWQ+crCxN0p0k9BrqvFveO+FJxo8mxU g29Q== 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=fozE5PDihCU0o3EbPMBx5uCzUUcUqKWorog8kzdfM4kldEyILEsqFYsnpPs+s42XP8 2I+r/YwVAxKJPgORHa2hTVCCefwjgmbBJ4Y8lqkgXNd+gPnUHruqQ9IAPUZCD3n7eNZW RWUoAsLTzNTM5LVhS1jxU0ZNECXfzZMq0xfd23H0Ts16mdYL3HRO9n24kbCuO5B6AkGR fgnZxbg3fiQGe33KR5SmSGL2Gyy/e0MpKUdFBX60LA/Tsp8wMOZkpjR1ZKpEGnKWTP3Z hv+6X3Z0sxPRZg3DnJZrH0fL+4IxQ/j8HDVX4M4MXvDdqWn7zpgJIc1TBz/iG42wRPQW 8J2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=D7axOv8P; 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 e19-20020a056402089300b0045cd10a4c20si1592437edy.321.2022.11.10.23.30.05; Thu, 10 Nov 2022 23:30:38 -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=D7axOv8P; 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 S232978AbiKKHOz (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Fri, 11 Nov 2022 02:14:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbiKKHOx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 11 Nov 2022 02:14:53 -0500 Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 015D1220E5 for <linux-kernel@vger.kernel.org>; Thu, 10 Nov 2022 23:14:50 -0800 (PST) From: Denis Arefev <arefev@swemel.ru> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1668150887; 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=D7axOv8PQ2u9o8K3jPlZllapQksFg7jwPTLfnBo9HKtZnm5QMrUKarmzk3KxJcylfjyBjE UcWlp7SyVruc4j6qmjg7RdhmT0GyVEmoDV64dLrZvEicUINhCFIOfsi2Rm3LhuqdUc6Y8k +7x+XYd7fzkFY0mU0c13V8dvwrIbThM= To: Harry Wentland <harry.wentland@amd.com> Cc: Leo Li <sunpeng.li@amd.com>, Alex Deucher <alexander.deucher@amd.com>, =?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>, David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, trufanov@swemel.ru Subject: [PATCH] amdgpu_dm_2027: Add pointer check Date: Fri, 11 Nov 2022 10:14:46 +0300 Message-Id: <20221111071446.22951-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?1749183982302037121?= X-GMAIL-MSGID: =?utf-8?q?1749183982302037121?= |
Series |
amdgpu_dm_2027: Add pointer check
|
|
Commit Message
Denis Arefev
Nov. 11, 2022, 7:14 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
The commit title should user the drm/amd/display prefix. It might also be good to be more specific, like: drm/amd/display: Check dc_resource_state_construct succeeded On 11/11/22 02:14, Denis Arefev wrote: > 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. > Does this fix a test case? If so, please describe. > 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); > + } I don't see how this won't leave the driver state in a mess. Are you sure this isn't a fatal error? Harry > > /* 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);