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

Commit b5296b93 authored by Amy Maloche's avatar Amy Maloche Committed by Sudhakar Manapati
Browse files

input: synaptics_i2c_rmi4: allocate memory for interrupt status



In synaptics_rmi4_i2c_read, intr_status is a char variant.  So
if num_of_intr_regs > 1, then intr_status will write 2 bytes.  This
will destroy the stack, so avoid it.

This patch is propagated from msm-3.4 kernel.
(commit: 5c7b5d59fe7d856e5cb20c7ff6e5dc3cc73fa892
input: synaptics_i2c_rmi4: allocate memory for interrupt status)
Also cleared the below checkpatch warning on msm-3.18 kernel
WARNING: Possible unnecessary 'out of memory' message
+               if (!intr_status) {
+                       dev_err(&rmi4_data->i2c_client->dev,

Change-Id: I5c16e491a84d3f8dd96a11810c060944a457b99a
Signed-off-by: default avatarAmy Maloche <amaloche@codeaurora.org>
Signed-off-by: default avatarSudhakar Manapati <smanap@codeaurora.org>
parent 63077eda
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -1082,17 +1082,21 @@ static int synaptics_rmi4_irq_enable(struct synaptics_rmi4_data *rmi4_data,
		bool enable)
{
	int retval = 0;
	unsigned char intr_status;
	unsigned char *intr_status;

	if (enable) {
		if (rmi4_data->irq_enabled)
			return retval;

		intr_status = kzalloc(rmi4_data->num_of_intr_regs, GFP_KERNEL);
		if (!intr_status)
			return -ENOMEM;
		/* Clear interrupts first */
		retval = synaptics_rmi4_i2c_read(rmi4_data,
				rmi4_data->f01_data_base_addr + 1,
				&intr_status,
				intr_status,
				rmi4_data->num_of_intr_regs);
		kfree(intr_status);
		if (retval < 0)
			return retval;