diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-01-22 22:23:41 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-01-22 22:23:41 -0500 |
| commit | 333478a7eb21245880c89aad166ad08478cc577d (patch) | |
| tree | 3b19b7234b0d5856e67dfd44c8416a5c695d0c28 | |
| parent | 0b0d4be6b4880c7199d41afe4d9a3f20f47fd9bb (diff) | |
| parent | 129699bb8c7572106b5bbb2407c2daee4727ccad (diff) | |
Merge branch 'for-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
Pull thermal management fixes from Zhang Rui:
- Fix a race condition that sysfs could be accessed before necessary
initialization in int340x thermal driver. (Aaron Hill)
- Fix a NULL vs IS_ERR() check in int340x thermal driver. (Dan
Carpenter)
* 'for-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux:
drivers: thermal: int340x_thermal: Fix sysfs race condition
thermal: int340x_thermal: Fix a NULL vs IS_ERR() check
| -rw-r--r-- | drivers/thermal/intel/int340x_thermal/processor_thermal_device.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c index 284cf2c5a8fd..8e1cf4d789be 100644 --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c | |||
| @@ -84,7 +84,12 @@ static ssize_t power_limit_##index##_##suffix##_show(struct device *dev, \ | |||
| 84 | struct pci_dev *pci_dev; \ | 84 | struct pci_dev *pci_dev; \ |
| 85 | struct platform_device *pdev; \ | 85 | struct platform_device *pdev; \ |
| 86 | struct proc_thermal_device *proc_dev; \ | 86 | struct proc_thermal_device *proc_dev; \ |
| 87 | \ | 87 | \ |
| 88 | if (proc_thermal_emum_mode == PROC_THERMAL_NONE) { \ | ||
| 89 | dev_warn(dev, "Attempted to get power limit before device was initialized!\n"); \ | ||
| 90 | return 0; \ | ||
| 91 | } \ | ||
| 92 | \ | ||
| 88 | if (proc_thermal_emum_mode == PROC_THERMAL_PLATFORM_DEV) { \ | 93 | if (proc_thermal_emum_mode == PROC_THERMAL_PLATFORM_DEV) { \ |
| 89 | pdev = to_platform_device(dev); \ | 94 | pdev = to_platform_device(dev); \ |
| 90 | proc_dev = platform_get_drvdata(pdev); \ | 95 | proc_dev = platform_get_drvdata(pdev); \ |
| @@ -298,11 +303,6 @@ static int proc_thermal_add(struct device *dev, | |||
| 298 | *priv = proc_priv; | 303 | *priv = proc_priv; |
| 299 | 304 | ||
| 300 | ret = proc_thermal_read_ppcc(proc_priv); | 305 | ret = proc_thermal_read_ppcc(proc_priv); |
| 301 | if (!ret) { | ||
| 302 | ret = sysfs_create_group(&dev->kobj, | ||
| 303 | &power_limit_attribute_group); | ||
| 304 | |||
| 305 | } | ||
| 306 | if (ret) | 306 | if (ret) |
| 307 | return ret; | 307 | return ret; |
| 308 | 308 | ||
| @@ -316,8 +316,7 @@ static int proc_thermal_add(struct device *dev, | |||
| 316 | 316 | ||
| 317 | proc_priv->int340x_zone = int340x_thermal_zone_add(adev, ops); | 317 | proc_priv->int340x_zone = int340x_thermal_zone_add(adev, ops); |
| 318 | if (IS_ERR(proc_priv->int340x_zone)) { | 318 | if (IS_ERR(proc_priv->int340x_zone)) { |
| 319 | ret = PTR_ERR(proc_priv->int340x_zone); | 319 | return PTR_ERR(proc_priv->int340x_zone); |
| 320 | goto remove_group; | ||
| 321 | } else | 320 | } else |
| 322 | ret = 0; | 321 | ret = 0; |
| 323 | 322 | ||
| @@ -331,9 +330,6 @@ static int proc_thermal_add(struct device *dev, | |||
| 331 | 330 | ||
| 332 | remove_zone: | 331 | remove_zone: |
| 333 | int340x_thermal_zone_remove(proc_priv->int340x_zone); | 332 | int340x_thermal_zone_remove(proc_priv->int340x_zone); |
| 334 | remove_group: | ||
| 335 | sysfs_remove_group(&proc_priv->dev->kobj, | ||
| 336 | &power_limit_attribute_group); | ||
| 337 | 333 | ||
| 338 | return ret; | 334 | return ret; |
| 339 | } | 335 | } |
| @@ -364,7 +360,10 @@ static int int3401_add(struct platform_device *pdev) | |||
| 364 | platform_set_drvdata(pdev, proc_priv); | 360 | platform_set_drvdata(pdev, proc_priv); |
| 365 | proc_thermal_emum_mode = PROC_THERMAL_PLATFORM_DEV; | 361 | proc_thermal_emum_mode = PROC_THERMAL_PLATFORM_DEV; |
| 366 | 362 | ||
| 367 | return 0; | 363 | dev_info(&pdev->dev, "Creating sysfs group for PROC_THERMAL_PLATFORM_DEV\n"); |
| 364 | |||
| 365 | return sysfs_create_group(&pdev->dev.kobj, | ||
| 366 | &power_limit_attribute_group); | ||
| 368 | } | 367 | } |
| 369 | 368 | ||
| 370 | static int int3401_remove(struct platform_device *pdev) | 369 | static int int3401_remove(struct platform_device *pdev) |
| @@ -423,7 +422,7 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, | |||
| 423 | proc_priv->soc_dts = intel_soc_dts_iosf_init( | 422 | proc_priv->soc_dts = intel_soc_dts_iosf_init( |
| 424 | INTEL_SOC_DTS_INTERRUPT_MSI, 2, 0); | 423 | INTEL_SOC_DTS_INTERRUPT_MSI, 2, 0); |
| 425 | 424 | ||
| 426 | if (proc_priv->soc_dts && pdev->irq) { | 425 | if (!IS_ERR(proc_priv->soc_dts) && pdev->irq) { |
| 427 | ret = pci_enable_msi(pdev); | 426 | ret = pci_enable_msi(pdev); |
| 428 | if (!ret) { | 427 | if (!ret) { |
| 429 | ret = request_threaded_irq(pdev->irq, NULL, | 428 | ret = request_threaded_irq(pdev->irq, NULL, |
| @@ -441,7 +440,10 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, | |||
| 441 | dev_err(&pdev->dev, "No auxiliary DTSs enabled\n"); | 440 | dev_err(&pdev->dev, "No auxiliary DTSs enabled\n"); |
| 442 | } | 441 | } |
| 443 | 442 | ||
| 444 | return 0; | 443 | dev_info(&pdev->dev, "Creating sysfs group for PROC_THERMAL_PCI\n"); |
| 444 | |||
| 445 | return sysfs_create_group(&pdev->dev.kobj, | ||
| 446 | &power_limit_attribute_group); | ||
| 445 | } | 447 | } |
| 446 | 448 | ||
| 447 | static void proc_thermal_pci_remove(struct pci_dev *pdev) | 449 | static void proc_thermal_pci_remove(struct pci_dev *pdev) |
