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

Commit e3ac1ac9 authored by Shantanu Jain's avatar Shantanu Jain Committed by Gerrit - the friendly Code Review server
Browse files

input: synaptics_dsx: Correct error path for write_buf memory allocation



Correct the error path for the memory allocation of write_buf variable
in Synaptics DSX touch driver. Properly free the memory associated to it.

Change-Id: Id66a123332d8a88519119e42d21d338abe550dbf
Signed-off-by: default avatarShantanu Jain <shjain@codeaurora.org>
parent 977e5aaf
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -3588,10 +3588,11 @@ static int synaptics_rmi4_probe(struct platform_device *pdev)
	rmi4_data->fingers_on_2d = false;
	rmi4_data->update_coords = true;

	rmi4_data->write_buf = devm_kzalloc(&pdev->dev, I2C_WRITE_BUF_MAX_LEN,
					GFP_KERNEL);
	if (!rmi4_data->write_buf)
		return -ENOMEM;
	rmi4_data->write_buf = kzalloc(I2C_WRITE_BUF_MAX_LEN, GFP_KERNEL);
	if (!rmi4_data->write_buf) {
		retval = -ENOMEM;
		goto err_write_buf_alloc;
	}
	rmi4_data->write_buf_len = I2C_WRITE_BUF_MAX_LEN;

	rmi4_data->irq_enable = synaptics_rmi4_irq_enable;
@@ -3811,6 +3812,8 @@ err_regulator_enable:
	regulator_put(rmi4_data->regulator_vdd);
	regulator_put(rmi4_data->regulator_avdd);
err_regulator_configure:
	kfree(rmi4_data->write_buf);
err_write_buf_alloc:
	kfree(rmi4_data);

	return retval;
@@ -3905,6 +3908,7 @@ static int synaptics_rmi4_remove(struct platform_device *pdev)
		regulator_put(rmi4_data->regulator_avdd);
	}

	kfree(rmi4_data->write_buf);
	kfree(rmi4_data);

	return 0;
+2 −3
Original line number Diff line number Diff line
@@ -148,9 +148,8 @@ static int synaptics_rmi4_i2c_write(struct synaptics_rmi4_data *rmi4_data,
	 * Reassign memory for write_buf in case length is greater than 32 bytes
	 */
	if (rmi4_data->write_buf_len < length + 1) {
		devm_kfree(rmi4_data->pdev->dev.parent, rmi4_data->write_buf);
		rmi4_data->write_buf = devm_kzalloc(rmi4_data->pdev->dev.parent,
					length + 1, GFP_KERNEL);
		kfree(rmi4_data->write_buf);
		rmi4_data->write_buf = kzalloc(length + 1, GFP_KERNEL);
		if (!rmi4_data->write_buf) {
			rmi4_data->write_buf_len = 0;
			retval = -ENOMEM;