Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2385827lqp; Sun, 24 Mar 2024 17:06:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWtPc18f3sfnS8n7sDHdraZotZtN8uiLc4eTKLA3vsJohFH52dkB2SghArFTPPwEno6kHvsZdiBQuK28UAG8sL3IDvpcPeb/wVkFSTvaw== X-Google-Smtp-Source: AGHT+IGMMliDFFooGlxXTHgnFKoZCxhm00HNx47gRo+kCWOOkWcG9/PGk1NFnqYhVgQcqOrYuEMw X-Received: by 2002:a17:906:4a56:b0:a47:3951:ce96 with SMTP id a22-20020a1709064a5600b00a473951ce96mr4165953ejv.4.1711325207485; Sun, 24 Mar 2024 17:06:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711325207; cv=pass; d=google.com; s=arc-20160816; b=pckWIKf9WUeXYCTxdi6AWMDTJyNpqoOaM7djFD2m5VI7rkpBaYW+XluHV4vJ2wiIty mMPKWyZUPZ6n6A4Uu+VliVgbWUczFQt5pocIbHvo+i2bq8kr+4ygQK4R6hl/PUmjMMLd tt1ZJSy3uBBVXRcE+E0uakqrNSCFaefm9qU94+GZ/LnQxWVc3MLaFyu4KaRQOtE0gFVf A1KIMlJm/SK8lbX6+2R/4Rjzt722/9ucJrtfVij8hgPeH2vkXVGsb03qND9HZAAgWCNt G/o+R/O2/ykuCyd6p34YSqAo3Rp7dWu5tJM8Vtg/uNpgRcWQdOslH4ZnWVsAp8V2kma9 6NwQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BRMT2GnpeJM9J83BPcL9spJqu1NCHf/ZSKj5vx7u44c=; fh=wlFpxNeQaQeq6aSLtHY+shDwCEWDAginMDP1QqavkPU=; b=u+iJDbMnJ/tPS2w4ubEWDMEqSSJRCtfLO1L7i1ZsMSc1heayYtZLN9BOAg8EpWn251 a84guG/rtkidTcpFwokPyPT9zpSQCLIijJbF2Od7RdUoAjGTy6hntgQItZyvGhUf1/tH 3qshu98aORYYuMPbzhptJpyXbV4yFMWLqKlSA39SSkCrEZ+h4zd2EN6ygf5WWIwh2cFw Kfc4iRjoXDnCNCNUpCVqvyc0sczFvhks2KQ+kA/WuYqF9SVOXBtt++QWwzVRHZVsFOWr UzQtPtAWTuPe2kTtTgY1A6wjIZ2YV87+yDtjYbPcO8OTinNUvE5TTEyf1cB+6jP4GyLF o+tA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aw7By5aA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113310-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113310-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id wp12-20020a170907060c00b00a44d0209395si1985289ejb.915.2024.03.24.17.06.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:06:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113310-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aw7By5aA; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113310-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113310-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 306401F227B2 for ; Mon, 25 Mar 2024 00:06:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4386A13CDF2; Sun, 24 Mar 2024 22:41:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aw7By5aA" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51F5A192716; Sun, 24 Mar 2024 22:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320111; cv=none; b=EVLPJmJUN4s1NIj8qlpfGPj6/3XsQT6eXUYO0zK6Wfs832tmZ0hCTpvvIHPYc3rPUq9JRrlP9jxzM3KInqgfVHtJhOYF+Mk/B1+shB1fgt5HC/hjTloOuebd66djCA1OUUau556GdGQ3QXxFSY9Sv6wcM0ZRqNulYp0kQQqAfZ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320111; c=relaxed/simple; bh=RwvNd7l2AEUCXjEWxoRmWTdoNHcz76iSxEq2t5vJVXI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R9cmiIW/95oMwnIdj/eyIwQn4OgGaWGqGiF9IjaEwGxo9cc/ucvLEATAWzcLO2bQw77kDRXFdtclNkQqwQhqMb3bGqT1o/zHjpu7wpQHLOs6aZ//ZwOr7RpsFlPWSKsF+pUfR5tyXp8hLvswVDlKFbuKVx+556Axkv3YoIszAy8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aw7By5aA; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91539C433F1; Sun, 24 Mar 2024 22:41:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320111; bh=RwvNd7l2AEUCXjEWxoRmWTdoNHcz76iSxEq2t5vJVXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aw7By5aAKGU/JBpFdKP2AzfGXN/RTZDzHp9+WNRSdqQew1fNIvD51gH32x+43QQcp 8DYBZKyFSJTEuxTFSX7VRu6crW53VOrtMmXOH09uXIHvIvT0ouDkLtx+ikRHnxXZ0r MMi5bz9TVu1xI8ozNHzg8U40w8L9PcWV6jyEB+hu/hxvEd/1b0fqtODZxReAOxiyQ7 RomgiLkNx80LcJ62/MzZhv6FpgiLZl2Loy9jo5UWWhIbp+mhBoY2RY//NNzfDxQFRf os401OlSp1LQfqNrGWTB0gGtFhlELRc2axzvNf8KA4YXpLipnAdvGyRfPHuo0lOb99 /jqUWkHTynyPg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nikita Zhandarovich , Alex Deucher , Sasha Levin Subject: [PATCH 6.8 419/715] drm/amd/display: fix NULL checks for adev->dm.dc in amdgpu_dm_fini() Date: Sun, 24 Mar 2024 18:29:58 -0400 Message-ID: <20240324223455.1342824-420-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Nikita Zhandarovich [ Upstream commit 2a3cfb9a24a28da9cc13d2c525a76548865e182c ] 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 Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- .../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 1a9bbb04bd5e2..8083e7156afcf 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -1929,17 +1929,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.43.0