Skip to contentSkip to conversation

thermal: sysfs: lock tz when access sustainable power properties

DISCUSSION Dan Carpenter 1 participant 1 message Jun 2, 2016

lore
Share & tools
lore
#0 lore raw

Hello Eduardo Valentin,

This is a semi-automatic email about new static checker warnings.

The patch 58601ec845aa: "thermal: sysfs: lock tz when access sustainable power properties" from May 30, 2016, leads to the following Smatch complaint:

drivers/thermal/thermal_sysfs.c:376 sustainable_power_show()

	 warn: variable dereferenced before check 'tz->tzp' (see line 373)

drivers/thermal/thermal_sysfs.c
372 mutex_lock(&tz->lock);

   373		sustainable_power = tz->tzp->sustainable_power;
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

New dereference.

374 mutex_unlock(&tz->lock);
375
376 if (tz->tzp)

                    ^^^^^^^

Old code assumed this could be NULL.

   377			return sprintf(buf, "%u\n", sustainable_power);
   378		else

regards,
dan carpenter