cb58a1e
Bugzilla: 1090161
cb58a1e
Upstream-status: sent https://patchwork.kernel.org/patch/4055781/
cb58a1e
cb58a1e
From patchwork Thu Apr 24 22:26:38 2014
cb58a1e
Content-Type: text/plain; charset="utf-8"
cb58a1e
MIME-Version: 1.0
cb58a1e
Content-Transfer-Encoding: 7bit
cb58a1e
Subject: HID: rmi: do not fetch more than 16 bytes in a query
cb58a1e
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
cb58a1e
X-Patchwork-Id: 4055781
cb58a1e
Message-Id: <1398378398-24825-1-git-send-email-benjamin.tissoires@redhat.com>
cb58a1e
To: Andrew Duggan <aduggan@synaptics.com>,
cb58a1e
	Christopher Heiny <cheiny@synaptics.com>,
cb58a1e
	Jiri Kosina <jkosina@suse.cz>, linux-input@vger.kernel.org,
cb58a1e
	linux-kernel@vger.kernel.org
cb58a1e
Date: Thu, 24 Apr 2014 18:26:38 -0400
cb58a1e
cb58a1e
A firmware bug is present on the XPS Haswell edition which silently
cb58a1e
split the request in two responses when the caller ask for a read of
cb58a1e
more than 16 bytes.
cb58a1e
The FW sends the first 16 then the 4 next, but it says that it answered
cb58a1e
the 20 bytes in the first report.
cb58a1e
cb58a1e
This occurs only on the retrieving of the min/max of X and Y of the F11
cb58a1e
function.
cb58a1e
We only use the first 10 bytes of the Ctrl register, so we can get only
cb58a1e
those 10 bytes to prevent the bug from happening.
cb58a1e
cb58a1e
Resolves:
cb58a1e
https://bugzilla.redhat.com/show_bug.cgi?id=1090161
cb58a1e
cb58a1e
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
cb58a1e
cb58a1e
---
cb58a1e
drivers/hid/hid-rmi.c | 11 ++++++++---
cb58a1e
 1 file changed, 8 insertions(+), 3 deletions(-)
cb58a1e
cb58a1e
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
cb58a1e
index 7da9509..cee89c9 100644
cb58a1e
--- a/drivers/hid/hid-rmi.c
cb58a1e
+++ b/drivers/hid/hid-rmi.c
cb58a1e
@@ -613,10 +613,15 @@ static int rmi_populate_f11(struct hid_device *hdev)
cb58a1e
 		}
cb58a1e
 	}
cb58a1e
 
cb58a1e
-	/* retrieve the ctrl registers */
cb58a1e
-	ret = rmi_read_block(hdev, data->f11.control_base_addr, buf, 20);
cb58a1e
+	/*
cb58a1e
+	 * retrieve the ctrl registers
cb58a1e
+	 * the ctrl register has a size of 20 but a fw bug split it into 16 + 4,
cb58a1e
+	 * and there is no way to know if the first 20 bytes are here or not.
cb58a1e
+	 * We use only the first 10 bytes, so get only them.
cb58a1e
+	 */
cb58a1e
+	ret = rmi_read_block(hdev, data->f11.control_base_addr, buf, 10);
cb58a1e
 	if (ret) {
cb58a1e
-		hid_err(hdev, "can not read ctrl block of size 20: %d.\n", ret);
cb58a1e
+		hid_err(hdev, "can not read ctrl block of size 10: %d.\n", ret);
cb58a1e
 		return ret;
cb58a1e
 	}
cb58a1e