Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1409883 > unrolled thread
| Started by | Eduardo Valentin <edubezval@gmail.com> |
|---|---|
| First post | 2016-05-31 08:40 +0200 |
| Last post | 2016-05-31 08:40 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 01/15] thermal: sysfs: lock tz in type_show Eduardo Valentin <edubezval@gmail.com> - 2016-05-31 08:40 +0200
| From | Eduardo Valentin <edubezval@gmail.com> |
|---|---|
| Date | 2016-05-31 08:40 +0200 |
| Subject | [PATCH 01/15] thermal: sysfs: lock tz in type_show |
| Message-ID | <rELvk-7hB-39@gated-at.bofh.it> |
Avoid race while accessing tz->type.
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
---
drivers/thermal/thermal_sysfs.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index 4136b71..ee983ca 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -29,8 +29,13 @@ static ssize_t
type_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct thermal_zone_device *tz = to_thermal_zone(dev);
+ char *type;
- return sprintf(buf, "%s\n", tz->type);
+ mutex_lock(&tz->lock);
+ type = tz->type;
+ mutex_unlock(&tz->lock);
+
+ return sprintf(buf, "%s\n", type);
}
static ssize_t
--
2.1.4
Back to top | Article view | linux.kernel
csiph-web