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

Commit c9fa254e authored by Himanshu Aggarwal's avatar Himanshu Aggarwal Committed by Gerrit - the friendly Code Review server
Browse files

input: synaptics_fw_update: fix insufficient bounds checking



Possible values of config_area are between 0 and 3. The patch
adds bounds checking in fwu_sysfs_config_area_store() function.
Also use kstrtou16() for parsing the config_area.

This patch is propagated from msm-3.10 kernel
(commit: 01cbd318c9d5ab37135feb352906f375be0a3fd8
input: synaptics_fw_update: fix insufficient bounds checking)

Change-Id: Ia0b58f1b5a359c67f420012876431dac920ecfbd
Signed-off-by: default avatarHimanshu Aggarwal <haggarwa@codeaurora.org>
parent 364c2967
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -1907,12 +1907,20 @@ static ssize_t fwu_sysfs_config_area_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
{
	int retval;
	unsigned long config_area;
	unsigned short config_area;
	struct synaptics_rmi4_data *rmi4_data = fwu->rmi4_data;

	retval = kstrtoul(buf, 10, &config_area);
	retval = kstrtou16(buf, 10, &config_area);
	if (retval)
		return retval;

	if (config_area < 0x00 || config_area > 0x03) {
		dev_err(&rmi4_data->i2c_client->dev,
			"%s: Incorrect value of config_area\n",
			__func__);
		return -EINVAL;
	}

	fwu->config_area = config_area;

	return count;