Эх сурвалжийг харах

intel_th: Hold output driver module reference while capture is active

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>
Alexander Shishkin 9 жил өмнө
parent
commit
e2ea295baf

+ 5 - 0
drivers/hwtracing/intel_th/core.c

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