From fa1aff5e8e7464851470f29eeae45bde1f089ce1 Mon Sep 17 00:00:00 2001 From: Heikki Krogerus Date: Mon, 17 Feb 2020 18:07:17 +0300 Subject: [PATCH] usb: typec: ucsi: displayport: Fix potential NULL pointer dereference In ucsi_displayport_remove_partner(), if the DisplayPort alt mode was never registered, then there is also no driver data for it. Adding a check to make sure there really is driver data for the device before modifying it. Signed-off-by: Heikki Krogerus --- drivers/usb/typec/ucsi/displayport.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/typec/ucsi/displayport.c b/drivers/usb/typec/ucsi/displayport.c index 0f1273ae086c..261131c9e37c 100644 --- a/drivers/usb/typec/ucsi/displayport.c +++ b/drivers/usb/typec/ucsi/displayport.c @@ -271,6 +271,9 @@ void ucsi_displayport_remove_partner(struct typec_altmode *alt) return; dp = typec_altmode_get_drvdata(alt); + if (!dp) + return; + dp->data.conf = 0; dp->data.status = 0; dp->initialized = false; -- 2.25.0