diff options
author | Alexander Shishkin <alexander.shishkin@linux.intel.com> | 2016-03-07 17:04:45 +0200 |
---|---|---|
committer | Alexander Shishkin <alexander.shishkin@linux.intel.com> | 2016-04-08 16:11:58 +0300 |
commit | f18a9531f6da9aba2920a3a5f166dba5a20592a0 (patch) | |
tree | 4e88611c1a4817d6d7a6dc81ef57e79527d18e08 /drivers/hwtracing/intel_th/core.c | |
parent | e8644e4c2aa5c52c357f63af9cc17ef5dce38396 (diff) | |
download | linux-stable-f18a9531f6da9aba2920a3a5f166dba5a20592a0.tar.gz linux-stable-f18a9531f6da9aba2920a3a5f166dba5a20592a0.tar.bz2 linux-stable-f18a9531f6da9aba2920a3a5f166dba5a20592a0.zip |
intel_th: Fix activating a subdevice without a driver
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>
Diffstat (limited to 'drivers/hwtracing/intel_th/core.c')
-rw-r--r-- | drivers/hwtracing/intel_th/core.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c index db0691929a60..20339470c2c6 100644 --- a/drivers/hwtracing/intel_th/core.c +++ b/drivers/hwtracing/intel_th/core.c @@ -183,7 +183,11 @@ static DEVICE_ATTR_RO(port); 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); @@ -195,7 +199,11 @@ static int intel_th_output_activate(struct intel_th_device *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); |