Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4fbc7d5e authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "drivers: thermal: Check NULL pointer before using it in thermal stat update"

parents 0409c532 e460e50d
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -898,6 +898,9 @@ void thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev,
{
	struct cooling_dev_stats *stats = cdev->stats;

	if (!stats)
		return;

	spin_lock(&stats->lock);

	if (stats->state == new_state)
@@ -919,6 +922,9 @@ static ssize_t total_trans_show(struct device *dev,
	struct cooling_dev_stats *stats = cdev->stats;
	int ret;

	if (!stats)
		return -ENODEV;

	spin_lock(&stats->lock);
	ret = sprintf(buf, "%u\n", stats->total_trans);
	spin_unlock(&stats->lock);
@@ -935,6 +941,9 @@ time_in_state_ms_show(struct device *dev, struct device_attribute *attr,
	ssize_t len = 0;
	int i;

	if (!stats)
		return -ENODEV;

	spin_lock(&stats->lock);
	update_time_in_state(stats);

@@ -953,8 +962,12 @@ reset_store(struct device *dev, struct device_attribute *attr, const char *buf,
{
	struct thermal_cooling_device *cdev = to_cooling_device(dev);
	struct cooling_dev_stats *stats = cdev->stats;
	int i, states = stats->max_states;
	int i, states;

	if (!stats)
		return -ENODEV;

	states = stats->max_states;
	spin_lock(&stats->lock);

	stats->total_trans = 0;
@@ -978,6 +991,9 @@ static ssize_t trans_table_show(struct device *dev,
	ssize_t len = 0;
	int i, j;

	if (!stats)
		return -ENODEV;

	len += snprintf(buf + len, PAGE_SIZE - len, " From  :    To\n");
	len += snprintf(buf + len, PAGE_SIZE - len, "       : ");
	for (i = 0; i < stats->max_states; i++) {