diff options
author | minskey guo <chaohong.guo@linux.intel.com> | 2010-09-17 02:03:27 -0400 |
---|---|---|
committer | Matthew Garrett <mjg@redhat.com> | 2010-10-05 14:59:06 -0400 |
commit | a7abda8d721359363d679c5f2de964f29419568c (patch) | |
tree | 8f0fe2df8a421a8b1f558a9952fffc2f9d411472 /drivers | |
parent | fed522f7ea780d195d5d3e55df95fee520136e17 (diff) |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/platform/x86/intel_ips.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c index 71dcc410f9d..bfa9c726054 100644 --- a/drivers/platform/x86/intel_ips.c +++ b/drivers/platform/x86/intel_ips.c | |||
@@ -940,7 +940,6 @@ static int ips_monitor(void *data) | |||
940 | kfree(mch_samples); | 940 | kfree(mch_samples); |
941 | kfree(cpu_samples); | 941 | kfree(cpu_samples); |
942 | kfree(mchp_samples); | 942 | kfree(mchp_samples); |
943 | kthread_stop(ips->adjust); | ||
944 | return -ENOMEM; | 943 | return -ENOMEM; |
945 | } | 944 | } |
946 | 945 | ||
@@ -1535,19 +1534,24 @@ static int ips_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1535 | ips_enable_cpu_turbo(ips); | 1534 | ips_enable_cpu_turbo(ips); |
1536 | ips->cpu_turbo_enabled = true; | 1535 | ips->cpu_turbo_enabled = true; |
1537 | 1536 | ||
1538 | /* Set up the work queue and monitor/adjust threads */ | 1537 | /* Create thermal adjust thread */ |
1539 | ips->monitor = kthread_run(ips_monitor, ips, "ips-monitor"); | 1538 | ips->adjust = kthread_create(ips_adjust, ips, "ips-adjust"); |
1540 | if (IS_ERR(ips->monitor)) { | 1539 | if (IS_ERR(ips->adjust)) { |
1541 | dev_err(&dev->dev, | 1540 | dev_err(&dev->dev, |
1542 | "failed to create thermal monitor thread, aborting\n"); | 1541 | "failed to create thermal adjust thread, aborting\n"); |
1543 | ret = -ENOMEM; | 1542 | ret = -ENOMEM; |
1544 | goto error_free_irq; | 1543 | goto error_free_irq; |
1544 | |||
1545 | } | 1545 | } |
1546 | 1546 | ||
1547 | ips->adjust = kthread_create(ips_adjust, ips, "ips-adjust"); | 1547 | /* |
1548 | if (IS_ERR(ips->adjust)) { | 1548 | * Set up the work queue and monitor thread. The monitor thread |
1549 | * will wake up ips_adjust thread. | ||
1550 | */ | ||
1551 | ips->monitor = kthread_run(ips_monitor, ips, "ips-monitor"); | ||
1552 | if (IS_ERR(ips->monitor)) { | ||
1549 | dev_err(&dev->dev, | 1553 | dev_err(&dev->dev, |
1550 | "failed to create thermal adjust thread, aborting\n"); | 1554 | "failed to create thermal monitor thread, aborting\n"); |
1551 | ret = -ENOMEM; | 1555 | ret = -ENOMEM; |
1552 | goto error_thread_cleanup; | 1556 | goto error_thread_cleanup; |
1553 | } | 1557 | } |
@@ -1566,7 +1570,7 @@ static int ips_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1566 | return ret; | 1570 | return ret; |
1567 | 1571 | ||
1568 | error_thread_cleanup: | 1572 | error_thread_cleanup: |
1569 | kthread_stop(ips->monitor); | 1573 | kthread_stop(ips->adjust); |
1570 | error_free_irq: | 1574 | error_free_irq: |
1571 | free_irq(ips->dev->irq, ips); | 1575 | free_irq(ips->dev->irq, ips); |
1572 | error_unmap: | 1576 | error_unmap: |