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

Commit 8e2de74e authored by Eliad Peller's avatar Eliad Peller Committed by Luciano Coelho
Browse files

wl12xx: wrong values are returned in gpio_power_write()



Return values were assigned to incorrect var / weren't assigned.
fix it, and defer mutex_lock after the sanity checks.

Signed-off-by: default avatarEliad Peller <eliad@wizery.com>
Signed-off-by: default avatarLuciano Coelho <coelho@ti.com>
parent bbba3e68
Loading
Loading
Loading
Loading
+4 −6
Original line number Original line Diff line number Diff line
@@ -261,27 +261,25 @@ static ssize_t gpio_power_write(struct file *file,
	unsigned long value;
	unsigned long value;
	int ret;
	int ret;


	mutex_lock(&wl->mutex);

	len = min(count, sizeof(buf) - 1);
	len = min(count, sizeof(buf) - 1);
	if (copy_from_user(buf, user_buf, len)) {
	if (copy_from_user(buf, user_buf, len)) {
		ret = -EFAULT;
		return -EFAULT;
		goto out;
	}
	}
	buf[len] = '\0';
	buf[len] = '\0';


	ret = strict_strtoul(buf, 0, &value);
	ret = strict_strtoul(buf, 0, &value);
	if (ret < 0) {
	if (ret < 0) {
		wl1271_warning("illegal value in gpio_power");
		wl1271_warning("illegal value in gpio_power");
		goto out;
		return -EINVAL;
	}
	}


	mutex_lock(&wl->mutex);

	if (value)
	if (value)
		wl1271_power_on(wl);
		wl1271_power_on(wl);
	else
	else
		wl1271_power_off(wl);
		wl1271_power_off(wl);


out:
	mutex_unlock(&wl->mutex);
	mutex_unlock(&wl->mutex);
	return count;
	return count;
}
}