intel_th: Hold output driver module reference while capture is active
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>
Fri, 8 Apr 2016 14:35:04 +0000 (17:35 +0300)
committerAlexander Shishkin <alexander.shishkin@linux.intel.com>
Fri, 8 Apr 2016 14:41:25 +0000 (17:41 +0300)
Right now it's possible to unload the output subdevice's driver while
the capture to this output is active. Prevent this by holding the
output driver's module reference.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Laurent Fert <laurent.fert@intel.com>
drivers/hwtracing/intel_th/core.c

index 20339470c2c6ad55facfe94c74475c13f8d395ba..1be543e8e42fc12b0e2e3bb5d335497a2c917b4c 100644 (file)
@@ -189,6 +189,9 @@ static int intel_th_output_activate(struct intel_th_device *thdev)
        if (!thdrv)
                return -ENODEV;
 
+       if (!try_module_get(thdrv->driver.owner))
+               return -ENODEV;
+
        if (thdrv->activate)
                return thdrv->activate(thdev);
 
@@ -209,6 +212,8 @@ static void intel_th_output_deactivate(struct intel_th_device *thdev)
                thdrv->deactivate(thdev);
        else
                intel_th_trace_disable(thdev);
+
+       module_put(thdrv->driver.owner);
 }
 
 static ssize_t active_show(struct device *dev, struct device_attribute *attr,