mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-02-26 15:39:59 +00:00
NULL pointer might be used in ips_monitor()
The patch is to create ips_adjust thread before ips_monitor begins to run because the latter will kthread_stop() or wake up the former via ips->adjust pointer. Without this change, it is possible that ips->adjust is NULL when kthread_stop() or wake_up_process() is called in ips_monitor(). Signed-off-by: minskey guo <chaohong.guo@intel.com> Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: Matthew Garrett <mjg@redhat.com>
This commit is contained in:
parent
fed522f7ea
commit
a7abda8d72
@ -940,7 +940,6 @@ static int ips_monitor(void *data)
|
|||||||
kfree(mch_samples);
|
kfree(mch_samples);
|
||||||
kfree(cpu_samples);
|
kfree(cpu_samples);
|
||||||
kfree(mchp_samples);
|
kfree(mchp_samples);
|
||||||
kthread_stop(ips->adjust);
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1535,20 +1534,25 @@ static int ips_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
|||||||
ips_enable_cpu_turbo(ips);
|
ips_enable_cpu_turbo(ips);
|
||||||
ips->cpu_turbo_enabled = true;
|
ips->cpu_turbo_enabled = true;
|
||||||
|
|
||||||
/* Set up the work queue and monitor/adjust threads */
|
/* Create thermal adjust thread */
|
||||||
ips->monitor = kthread_run(ips_monitor, ips, "ips-monitor");
|
|
||||||
if (IS_ERR(ips->monitor)) {
|
|
||||||
dev_err(&dev->dev,
|
|
||||||
"failed to create thermal monitor thread, aborting\n");
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto error_free_irq;
|
|
||||||
}
|
|
||||||
|
|
||||||
ips->adjust = kthread_create(ips_adjust, ips, "ips-adjust");
|
ips->adjust = kthread_create(ips_adjust, ips, "ips-adjust");
|
||||||
if (IS_ERR(ips->adjust)) {
|
if (IS_ERR(ips->adjust)) {
|
||||||
dev_err(&dev->dev,
|
dev_err(&dev->dev,
|
||||||
"failed to create thermal adjust thread, aborting\n");
|
"failed to create thermal adjust thread, aborting\n");
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
goto error_free_irq;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set up the work queue and monitor thread. The monitor thread
|
||||||
|
* will wake up ips_adjust thread.
|
||||||
|
*/
|
||||||
|
ips->monitor = kthread_run(ips_monitor, ips, "ips-monitor");
|
||||||
|
if (IS_ERR(ips->monitor)) {
|
||||||
|
dev_err(&dev->dev,
|
||||||
|
"failed to create thermal monitor thread, aborting\n");
|
||||||
|
ret = -ENOMEM;
|
||||||
goto error_thread_cleanup;
|
goto error_thread_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1566,7 +1570,7 @@ static int ips_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
error_thread_cleanup:
|
error_thread_cleanup:
|
||||||
kthread_stop(ips->monitor);
|
kthread_stop(ips->adjust);
|
||||||
error_free_irq:
|
error_free_irq:
|
||||||
free_irq(ips->dev->irq, ips);
|
free_irq(ips->dev->irq, ips);
|
||||||
error_unmap:
|
error_unmap:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user