aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>2016-03-07 10:04:45 -0500
committerAlexander Shishkin <alexander.shishkin@linux.intel.com>2016-04-08 09:11:58 -0400
commitf18a9531f6da9aba2920a3a5f166dba5a20592a0 (patch)
tree4e88611c1a4817d6d7a6dc81ef57e79527d18e08
parente8644e4c2aa5c52c357f63af9cc17ef5dce38396 (diff)
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>
-rw-r--r--drivers/hwtracing/intel_th/core.c12
-rw-r--r--drivers/hwtracing/intel_th/intel_th.h3
2 files changed, 13 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);
183 183
184static int intel_th_output_activate(struct intel_th_device *thdev) 184static int intel_th_output_activate(struct intel_th_device *thdev)
185{ 185{
186 struct intel_th_driver *thdrv = to_intel_th_driver(thdev->dev.driver); 186 struct intel_th_driver *thdrv =
187 to_intel_th_driver_or_null(thdev->dev.driver);
188
189 if (!thdrv)
190 return -ENODEV;
187 191
188 if (thdrv->activate) 192 if (thdrv->activate)
189 return thdrv->activate(thdev); 193 return thdrv->activate(thdev);
@@ -195,7 +199,11 @@ static int intel_th_output_activate(struct intel_th_device *thdev)
195 199
196static void intel_th_output_deactivate(struct intel_th_device *thdev) 200static void intel_th_output_deactivate(struct intel_th_device *thdev)
197{ 201{
198 struct intel_th_driver *thdrv = to_intel_th_driver(thdev->dev.driver); 202 struct intel_th_driver *thdrv =
203 to_intel_th_driver_or_null(thdev->dev.driver);
204
205 if (!thdrv)
206 return;
199 207
200 if (thdrv->deactivate) 208 if (thdrv->deactivate)
201 thdrv->deactivate(thdev); 209 thdrv->deactivate(thdev);
diff --git a/drivers/hwtracing/intel_th/intel_th.h b/drivers/hwtracing/intel_th/intel_th.h
index 15ebd48a29f2..0df22e30673d 100644
--- a/drivers/hwtracing/intel_th/intel_th.h
+++ b/drivers/hwtracing/intel_th/intel_th.h
@@ -151,6 +151,9 @@ struct intel_th_driver {
151#define to_intel_th_driver(_d) \ 151#define to_intel_th_driver(_d) \
152 container_of((_d), struct intel_th_driver, driver) 152 container_of((_d), struct intel_th_driver, driver)
153 153
154#define to_intel_th_driver_or_null(_d) \
155 ((_d) ? to_intel_th_driver(_d) : NULL)
156
154static inline struct intel_th_device * 157static inline struct intel_th_device *
155to_intel_th_hub(struct intel_th_device *thdev) 158to_intel_th_hub(struct intel_th_device *thdev)
156{ 159{