blob: f30ec7091959d2ccb549725ab0a42a940562d6a2 [file] [log] [blame]
From 658aefaf188000c34a2fa20e7d0f76d81be94d88 Mon Sep 17 00:00:00 2001
From: Heikki Krogerus <>
Date: Wed, 11 Mar 2020 16:00:05 +0300
Subject: [PATCH] usb: typec: ucsi: displayport: Fix NULL pointer dereference
commit d16e7b62c5adcd13832c6b0ba364c3468d21b856 upstream.
If the registration of the DisplayPort was not successful,
or if the port does not support DisplayPort alt mode in the
first place, the function ucsi_displayport_remove_partner()
will fail with NULL pointer dereference when it attempts to
access the driver data.
Adding a check to the function to make sure there really is
driver data for the device before modifying it.
Fixes: af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode")
Reported-by: Andrea Gagliardi La Gala <>
Signed-off-by: Heikki Krogerus <>
Signed-off-by: Greg Kroah-Hartman <>
Signed-off-by: Paul Gortmaker <>
diff --git a/drivers/usb/typec/ucsi/displayport.c b/drivers/usb/typec/ucsi/displayport.c
index d99700cb4dca..2fee12f748fe 100644
--- a/drivers/usb/typec/ucsi/displayport.c
+++ b/drivers/usb/typec/ucsi/displayport.c
@@ -273,6 +273,9 @@ void ucsi_displayport_remove_partner(struct typec_altmode *alt)
dp = typec_altmode_get_drvdata(alt);
+ if (!dp)
+ return;
dp->data.conf = 0;
dp->data.status = 0;
dp->initialized = false;