From: Christophe JAILLET Date: Mon, 19 Mar 2018 20:53:26 +0000 (+0100) Subject: HID: alps: Report an error if we receive invalid data in 't4_read_write_register()' X-Git-Tag: v4.19~850^2~8^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=605f077290a594c75a952ad3b78e53d68c1895ae;p=platform%2Fkernel%2Flinux-rpi.git HID: alps: Report an error if we receive invalid data in 't4_read_write_register()' If the data received is not what is expected, we should return an error. Otherwise, we return 0 or a positive value which will be interpreted as success, but '*read_val' has not been updated. Fixes: 73196ebe134d ("HID: alps: add support for Alps T4 Touchpad device") Signed-off-by: Christophe JAILLET Signed-off-by: Jiri Kosina --- diff --git a/drivers/hid/hid-alps.c b/drivers/hid/hid-alps.c index b1eeb48..925396f 100644 --- a/drivers/hid/hid-alps.c +++ b/drivers/hid/hid-alps.c @@ -219,6 +219,8 @@ static int t4_read_write_register(struct hid_device *hdev, u32 address, goto exit_readbuf; } + ret = -EINVAL; + if (*(u32 *)&readbuf[6] != address) { dev_err(&hdev->dev, "read register address error (%x,%x)\n", *(u32 *)&readbuf[6], address);