Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3721970pxb; Mon, 24 Jan 2022 16:19:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMRjqSwl3AJZuFCXNmn+zN7116xaei9bqf9IpEHd7n0LM7WWaVMywLO7Qggo09wVYb6WFB X-Received: by 2002:a17:902:bd0a:b0:148:b21d:bf92 with SMTP id p10-20020a170902bd0a00b00148b21dbf92mr16393098pls.16.1643069960225; Mon, 24 Jan 2022 16:19:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643069960; cv=none; d=google.com; s=arc-20160816; b=zK5nA1m0ow4TRCd5v171rANN6xBikMVXEy/OawySjROjBgxjDBCbTtat6h9qJJPLYG /UR1xw+e2dErsTm2G0vp1MErIfBjx+TvLTjRFokgEd9wwML9xL6+07qaQ55aQdpSCDmh E0BtH1aB3kJlEbjdC+8XbGlOcIbv64+mOEa1htkqXXeyoBbPaWuMVaG3PZdtdFWsSnpM QURqRJZASmL296oDnH305tEzyLuSqc4Aw8nKgSV35HickuqrVmcuGb4A2CVk4lCAD+dT J9OWMTcr4AjyrZiNKZx018rouyYMxfZ7a0jWolwdam/HLKXaGYeqhqJNoMK02OxYOp4e dqsA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cH8NrkTPGp/b34TFXEtl4R5jQ6zfH/fE52CCqNm3iGg=; b=rS3Ii191wN0uI8lP/gyQVETtZ0/s4hjZ4csb/Fk5K2vlhKcqQmEoVRPriJ4xPE6BQ/ cNbGyhRvzTQLrgTOH4SpkaJBmDT1m88etp11JDk6e2P3KmRkJWFT7hKRO6FpWr6Z73SB nu+ol5gv/MI2zX8xCmXo78LcUnM5iz4VZxQsjjNosRwYDS/ZK5KqkwH8vgTxhaCRk0s5 cvElmKJvPLYYrME7i9P5PRNxxGOdKaikiz5Eogk7rY625GfXv34fd3hIcVOL6hj6GpIn degy8CQrXq96c6oa8J6ujjKFXjkj0mlVDnPwWnmEUDi/QnuFaWPSCvbqA0G1kZ7a4IUZ V5tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AymDe3G0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z21si674320pjq.133.2022.01.24.16.19.08; Mon, 24 Jan 2022 16:19:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AymDe3G0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2373314AbiAYANc (ORCPT + 99 others); Mon, 24 Jan 2022 19:13:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1839672AbiAXX2d (ORCPT ); Mon, 24 Jan 2022 18:28:33 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A79AC075955; Mon, 24 Jan 2022 13:34:08 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2BAD061305; Mon, 24 Jan 2022 21:34:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 103CCC340E4; Mon, 24 Jan 2022 21:34:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060047; bh=+gYox5gfMlmqNO1wkoe6FTEVu8N04dhY/8LJMhA6gtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AymDe3G0Zu2Myo6385zcKsllOXyiZ0Lj5vMfSmzGpX+gyatf+5k3u9LE8dFYNkZNs 5UrlDzct1VoLPqMKUFGfbY0jWNEf/DgjX5hb8zPTEB9I7LmZfFZB988lBJ5IWgif8y IXA3a84r+kbABDKJW1ifVEH1IIkwb6B+LAdNbXWc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Harry Wentland , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Alex Deucher , Sasha Levin Subject: [PATCH 5.16 0821/1039] drm/amd/display: invalid parameter check in dmub_hpd_callback Date: Mon, 24 Jan 2022 19:43:30 +0100 Message-Id: <20220124184152.897816208@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: José Expósito [ Upstream commit 978ffac878fd64039f95798b15b430032d2d89d5 ] The function performs a check on the "adev" input parameter, however, it is used before the check. Initialize the "dev" variable after the sanity check to avoid a possible NULL pointer dereference. Fixes: e27c41d5b0681 ("drm/amd/display: Support for DMUB HPD interrupt handling") Addresses-Coverity-ID: 1493909 ("Null pointer dereference") Reviewed-by: Harry Wentland Signed-off-by: José Expósito Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++- 1 file changed, 2 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 46d38d528468c..3a227e9d8dfcb 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -656,7 +656,7 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct dmub_notification *not struct drm_connector_list_iter iter; struct dc_link *link; uint8_t link_index = 0; - struct drm_device *dev = adev->dm.ddev; + struct drm_device *dev; if (adev == NULL) return; @@ -673,6 +673,7 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct dmub_notification *not link_index = notify->link_index; link = adev->dm.dc->links[link_index]; + dev = adev->dm.ddev; drm_connector_list_iter_begin(dev, &iter); drm_for_each_connector_iter(connector, &iter) { -- 2.34.1