If output subdevice driver is not loaded, activating it will try to
call its ->activate method and crash. Fix this by explicitly checking
for the driver.
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Laurent Fert <laurent.fert@intel.com>
 
 static int intel_th_output_activate(struct intel_th_device *thdev)
 {
-       struct intel_th_driver *thdrv = to_intel_th_driver(thdev->dev.driver);
+       struct intel_th_driver *thdrv =
+               to_intel_th_driver_or_null(thdev->dev.driver);
+
+       if (!thdrv)
+               return -ENODEV;
 
        if (thdrv->activate)
                return thdrv->activate(thdev);
 
 static void intel_th_output_deactivate(struct intel_th_device *thdev)
 {
-       struct intel_th_driver *thdrv = to_intel_th_driver(thdev->dev.driver);
+       struct intel_th_driver *thdrv =
+               to_intel_th_driver_or_null(thdev->dev.driver);
+
+       if (!thdrv)
+               return;
 
        if (thdrv->deactivate)
                thdrv->deactivate(thdev);
 
 #define to_intel_th_driver(_d)                                 \
        container_of((_d), struct intel_th_driver, driver)
 
+#define to_intel_th_driver_or_null(_d)         \
+       ((_d) ? to_intel_th_driver(_d) : NULL)
+
 static inline struct intel_th_device *
 to_intel_th_hub(struct intel_th_device *thdev)
 {