diff mbox series

[1/3] drm/i915/hdcp: Add encoder check in intel_hdcp_get_capability

Message ID 20240722064451.3610512-2-suraj.kandpal@intel.com (mailing list archive)
State New, archived
Headers show
Series Fix null pointer error in HDCP capability check | expand

Commit Message

Kandpal, Suraj July 22, 2024, 6:44 a.m. UTC
Sometimes during hotplug scenario or suspend/resume scenario encoder is
not always initialized when intel_hdcp_get_capability add
a check to avoid kernel null pointer dereference.

Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
---
 drivers/gpu/drm/i915/display/intel_hdcp.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Bhadane, Dnyaneshwar July 24, 2024, 6:07 p.m. UTC | #1
> -----Original Message-----
> From: Intel-xe <intel-xe-bounces@lists.freedesktop.org> On Behalf Of Suraj
> Kandpal
> Sent: Monday, July 22, 2024 12:15 PM
> To: intel-gfx@lists.freedesktop.org; intel-xe@lists.freedesktop.org
> Cc: Nautiyal, Ankit K <ankit.k.nautiyal@intel.com>; Kandpal, Suraj
> <suraj.kandpal@intel.com>
> Subject: [PATCH 1/3] drm/i915/hdcp: Add encoder check in
> intel_hdcp_get_capability
> 
> Sometimes during hotplug scenario or suspend/resume scenario encoder is
> not always initialized when intel_hdcp_get_capability add a check to avoid
> kernel null pointer dereference.
> 
> Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>


It is always good to handle this type of edge cases.
It Looks good to me.

Reviewed-by: Dnyaneshwar Bhadane <dnyaneshwar.bhadane@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_hdcp.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c
> b/drivers/gpu/drm/i915/display/intel_hdcp.c
> index 3ebe035f382e..05402ae6b569 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdcp.c
> +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
> @@ -203,11 +203,16 @@ int intel_hdcp_read_valid_bksv(struct
> intel_digital_port *dig_port,
>  /* Is HDCP1.4 capable on Platform and Sink */  bool
> intel_hdcp_get_capability(struct intel_connector *connector)  {
> -	struct intel_digital_port *dig_port =
> intel_attached_dig_port(connector);
> +	struct intel_digital_port *dig_port;
>  	const struct intel_hdcp_shim *shim = connector->hdcp.shim;
>  	bool capable = false;
>  	u8 bksv[5];
> 
> +	if (!intel_attached_encoder(connector))

> +		return capable;
> +
> +	dig_port = intel_attached_dig_port(connector);
> +
>  	if (!shim)
>  		return capable;
> 
> --
> 2.43.2
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c
index 3ebe035f382e..05402ae6b569 100644
--- a/drivers/gpu/drm/i915/display/intel_hdcp.c
+++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
@@ -203,11 +203,16 @@  int intel_hdcp_read_valid_bksv(struct intel_digital_port *dig_port,
 /* Is HDCP1.4 capable on Platform and Sink */
 bool intel_hdcp_get_capability(struct intel_connector *connector)
 {
-	struct intel_digital_port *dig_port = intel_attached_dig_port(connector);
+	struct intel_digital_port *dig_port;
 	const struct intel_hdcp_shim *shim = connector->hdcp.shim;
 	bool capable = false;
 	u8 bksv[5];
 
+	if (!intel_attached_encoder(connector))
+		return capable;
+
+	dig_port = intel_attached_dig_port(connector);
+
 	if (!shim)
 		return capable;