usb: typec: Prepare alt mode enter/exit reporting for UCSI alt mode support
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Fri, 1 Feb 2019 10:47:55 +0000 (13:47 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Feb 2019 09:25:12 +0000 (10:25 +0100)
Because of UCSI, we have to support alt mode enter/exit
reporting even when there is no alt mode driver bind to the
alt mode device. With UCSI a firmware handles the alternate
modes, and the modes are entered automatically from OS PoW.

Changing typec_altmode_update_active() so that the driver
module ref count is incremented/decremented only if there
really is a driver for the alt mode. That avoids a NULL
pointer dereference from happening when the driver is
missing.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/class.c

index 5db0593..41c0d79 100644 (file)
@@ -277,7 +277,7 @@ void typec_altmode_update_active(struct typec_altmode *adev, bool active)
        if (adev->active == active)
                return;
 
-       if (!is_typec_port(adev->dev.parent)) {
+       if (!is_typec_port(adev->dev.parent) && adev->dev.driver) {
                if (!active)
                        module_put(adev->dev.driver->owner);
                else