usb: typec: ucsi: displayport: Fix NULL pointer dereference
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Wed, 11 Mar 2020 13:00:05 +0000 (16:00 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Mar 2020 07:27:00 +0000 (08:27 +0100)
commit8faf1122f7294a6834b16c9a5093b5efe0b31390
treedb69e4f99bb93bd0c5678ae821d48478659cd0a9
parentafe493a13d5ad3d7bbb70f797440a18bcdf1cfca
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 <andrea.lagala@gmail.com>
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206365
Cc: stable@vger.kernel.org
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20200311130006.41288-2-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/ucsi/displayport.c