Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2772450pxb; Tue, 23 Feb 2021 15:40:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzHgzqXOV/NbdwRmE0TfuyfycsCOYZks20+Vt2lJ4co7MUTRY0PTSqcPNM5ELT0Ubwe06QI X-Received: by 2002:a17:906:2c51:: with SMTP id f17mr15600956ejh.49.1614123631165; Tue, 23 Feb 2021 15:40:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614123631; cv=none; d=google.com; s=arc-20160816; b=eHxhdW7qzMingpX7AOe6V8bcOBGyHxHaaI9de47WHXdGQAhJuyIlswdlyd1cwZtQ7u TSKHuk0/FhmLh9zs67j0bbrQcGis+54oGUhaW5UjQppVnyDxWxITDvGFHb4mD9Yda09k oo7nVFq3PKGkfzBTRR5h87MXiaZfTkvybQrJPtTUkVLpIJFXRpmmhUinAjnFaRcGCThO Ao6UhpUOhzIRUfx2m7A0kMJPvUroeBgyJOTw2T3vWPfumxBsyWCcKeu4hByITqjTnmtj UnhYGXMvLaBriMJj8ScsAaQkM3+UKAXVEXsDj9t1l9YRtGn20Ij0ggTnc665MtuBNkRq YHHg== 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:from; bh=iqArKj172EE7dyKyaj9dlYcVTaoUDtkOHNDJtkmHJj8=; b=SoE5NUjtDR5aPQdW+DRgmcaLCFj+qYMmXiNITr2Nlo+Pwcm2KCB+1ISEyzbQwl87lq bJ5F/MFoz7USg2YCXt6xzwySrQEo0cc4dg7yl1MfX/H6Fw6VDmvpC7UWjfX54DkC6jYb 6rsLZkYB1531hULOcQD87HLpEp5glVQd2qIidkCylZt8wRZ4cL96YcDQJCMaovI81ZO/ 2DHYaVFtI7kTjlQ+QGh2zNTD7sonhdSb0A43XZffrQj3ICdIR+TiyRTeaX4BTOX8jlr1 JuxAtfDDCgd4isi6jo3nTXTVnBD62ZCivbnt95iVJLcLcHRY+AdA8D1xZn3Nn6ItWPY/ 9m6g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 17si170737ejv.562.2021.02.23.15.39.53; Tue, 23 Feb 2021 15:40:31 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231974AbhBWTV5 (ORCPT + 99 others); Tue, 23 Feb 2021 14:21:57 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:55181 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231895AbhBWTUD (ORCPT ); Tue, 23 Feb 2021 14:20:03 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lEdDC-0007ll-2R; Tue, 23 Feb 2021 19:19:10 +0000 From: Colin King To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , Ramalingam C , Anshuman Gupta , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] drm/i915/hdcp: Fix null pointer dereference of connector->encoder Date: Tue, 23 Feb 2021 19:19:09 +0000 Message-Id: <20210223191909.16682-1-colin.king@canonical.com> X-Mailer: git-send-email 2.30.0 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: Colin Ian King The recent commit 6c63e6e14da7 ("drm/i915/hdcp: No HDCP when encoder is't initialized") added a null pointer check on connector->encoder hence implying that it could potentially be null. This means that the initialization of dig_port via the call intel_attached_dig_port may cause a null pointer dereference on connector->encoder. Fix this by only assigning dig_port after a null check has been performed on connector->encoder. Addresses-Coverity: ("Dereference before null check") Fixes: 36e5e7042b20 ("drm/i915: Don't fully disable HDCP on a port if multiple pipes are using it") Signed-off-by: Colin Ian King --- drivers/gpu/drm/i915/display/intel_hdcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c index ae1371c36a32..7525ea31766c 100644 --- a/drivers/gpu/drm/i915/display/intel_hdcp.c +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c @@ -2260,7 +2260,7 @@ int intel_hdcp_enable(struct intel_connector *connector, const struct intel_crtc_state *pipe_config, u8 content_type) { struct drm_i915_private *dev_priv = to_i915(connector->base.dev); - struct intel_digital_port *dig_port = intel_attached_dig_port(connector); + struct intel_digital_port *dig_port; struct intel_hdcp *hdcp = &connector->hdcp; unsigned long check_link_interval = DRM_HDCP_CHECK_PERIOD_MS; int ret = -EINVAL; @@ -2274,6 +2274,7 @@ int intel_hdcp_enable(struct intel_connector *connector, return -ENODEV; } + dig_port = intel_attached_dig_port(connector); mutex_lock(&hdcp->mutex); mutex_lock(&dig_port->hdcp_mutex); drm_WARN_ON(&dev_priv->drm, -- 2.30.0