Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3162161rdb; Tue, 6 Feb 2024 08:51:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFyaixX2Xv4vL5855xFcZmq2ZFelRuY+6ct9k+II3foKzeexOxRjt09pYkpSGqFoMx84E6Z X-Received: by 2002:a05:6830:109a:b0:6dd:de94:236f with SMTP id y26-20020a056830109a00b006ddde94236fmr3236725oto.13.1707238270709; Tue, 06 Feb 2024 08:51:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707238270; cv=pass; d=google.com; s=arc-20160816; b=U6H1l3K2w0PVXI1XSE62NQNg2ry1sKnohNPf+/+NVXRFf6I/SH1UqsWV0Wl8rgFdHz WRkiaRMtLpBpVWKdPxkzSY1lrXNXjvcYT2jccqkgYA91An7+1BNWHc+nXZuONDd8VhFa niEseclpKCfCmID48ITKGZCF0yxS1f/Rq4HT543kAA6CThs9Biv7EdLmDuIv8QCwRiuq 2b7nkkb4qCrZQdfZFbPGu7enmfxuUlDT2Sev2kX8QbpfWIt8Oz7Xez0j8SDr3EZsapGz h/Z/yBSJZ4hYtLgcaoQfley2mmz+o4HjqZbuEN5Nkky0HlawwvwyVzXDlEZSgEmlf/c4 ELJQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=HLcIFbhR74YUhjlIs4EQIhpyfbG2yLQQ/mGNodPMDLQ=; fh=Zb5/HrGic1+mUW6EbjwlSYtu1JhEasteFnNjAggPnE0=; b=MsvVYk51XHg6n/2bXvU/jBdnZlQmQ2tV+p2A2Rb8Sjew1W7IynjIvtn2eFs0Cf8YqV 64Ll/dA340a2aENpeT9ioro7tAICtsNPpUcWR2QOeqimV7oveOw+JlGHw9e1h1cbiAuv TrD+5r0ia+B5qEJCd/SC/rPaz/Hr07UY+FEKdL1Q/6gLRUs+xvOr3OrOagcJ+YdbyH3l H6McRnyvyDLHtgqzCW0W9UFwUiVvvW58ulMYxxf7IFmXSnGep2tqETpGQHKY276sLhHg SdDbK1bL81CPc8BMTk8TF8s3WH48W2fr/w2M39YuhHfTM26XM43LWWZsqyH2e47AAmOh o4oQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=fintech.ru); spf=pass (google.com: domain of linux-kernel+bounces-55338-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55338-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCUk+yfD6vn3uIznt1a0NROVt891QEZGSSE7UEI60kFeqnJSxMyVBwk96655lWcZiYWu9bq1yGm7tF5Pu4i341lItPB0Lz7aPbLANjeDGQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g6-20020ac87f46000000b0042c298f9a5dsi2769179qtk.60.2024.02.06.08.51.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 08:51:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55338-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=fintech.ru); spf=pass (google.com: domain of linux-kernel+bounces-55338-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55338-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 74EF11C24747 for ; Tue, 6 Feb 2024 16:51:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C6A879C5; Tue, 6 Feb 2024 16:51:05 +0000 (UTC) Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5163A6AB8 for ; Tue, 6 Feb 2024 16:51:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.54.195.159 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707238264; cv=none; b=RQpX94cjyfsd9745kVaTq74bAI/0tOWXAp69v0iGYwk3q9+lAaKOl/3T1DuIKaj2LKosaoE8WAlsEoB2K8ZuGoesOPbX+CaUhZBnfxqMWS6+jk07e3gcipS6crUS0qnoI7IJ670wRNfT4RWN8PtHeWA1u/uc6Ma8MA8sBVerKJU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707238264; c=relaxed/simple; bh=jh6cKf2Iuy2lDmKX7xyDcSvAYcsD9KFOaHpj5pI+mnc=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=bNESAHebJ07zqIGNumIJ5yVCw1e9lK2vsUTEgQT4dGBo5jSFUfDCgqMzcCfHtD/astJUUULd4+bhN0eMQhUdqf9Em/+KJq1oFMlKn5F8c1CqBmwVJHElbcV6BZE8/ataWi1DPRd+1naKN8ZEnGn9lQu3WNQ9ixbJKQgeNeyz39c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fintech.ru; spf=pass smtp.mailfrom=fintech.ru; arc=none smtp.client-ip=195.54.195.159 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fintech.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fintech.ru Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.169) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 6 Feb 2024 19:51:00 +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; Tue, 6 Feb 2024 19:50:59 +0300 From: Nikita Zhandarovich To: Harry Wentland , Leo Li , "Alex Deucher" , =?UTF-8?q?Christian=20K=C3=B6nig?= CC: Nikita Zhandarovich , Rodrigo Siqueira , "Pan, Xinhui" , David Airlie , Daniel Vetter , , , , Subject: [PATCH] drm/amd/display: fix NULL checks for adev->dm.dc in amdgpu_dm_fini() Date: Tue, 6 Feb 2024 08:50:56 -0800 Message-ID: <20240206165056.47116-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) Since 'adev->dm.dc' in amdgpu_dm_fini() might turn out to be NULL before the call to dc_enable_dmub_notifications(), check beforehand to ensure there will not be a possible NULL-ptr-deref there. Also, since commit 1e88eb1b2c25 ("drm/amd/display: Drop CONFIG_DRM_AMD_DC_HDCP") there are two separate checks for NULL in 'adev->dm.dc' before dc_deinit_callbacks() and dc_dmub_srv_destroy(). Clean up by combining them all under one 'if'. Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: 81927e2808be ("drm/amd/display: Support for DMUB AUX") Signed-off-by: Nikita Zhandarovich --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) 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 d292f290cd6e..46ac3e6f42bb 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -1938,17 +1938,15 @@ static void amdgpu_dm_fini(struct amdgpu_device *adev) adev->dm.hdcp_workqueue = NULL; } - if (adev->dm.dc) + if (adev->dm.dc) { dc_deinit_callbacks(adev->dm.dc); - - if (adev->dm.dc) dc_dmub_srv_destroy(&adev->dm.dc->ctx->dmub_srv); - - if (dc_enable_dmub_notifications(adev->dm.dc)) { - kfree(adev->dm.dmub_notify); - adev->dm.dmub_notify = NULL; - destroy_workqueue(adev->dm.delayed_hpd_wq); - adev->dm.delayed_hpd_wq = NULL; + if (dc_enable_dmub_notifications(adev->dm.dc)) { + kfree(adev->dm.dmub_notify); + adev->dm.dmub_notify = NULL; + destroy_workqueue(adev->dm.delayed_hpd_wq); + adev->dm.delayed_hpd_wq = NULL; + } } if (adev->dm.dmub_bo) -- 2.25.1