summaryrefslogtreecommitdiffstats
path: root/drivers/mfd/rave-sp.c
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2018-03-08 18:37:56 +0100
committerLee Jones <lee.jones@linaro.org>2018-05-16 10:21:48 +0200
commit5112cab38c76c28f973def1a9c8b881f2dc81a48 (patch)
tree14614d5732dc5bb98972a859afd30823e88ae695 /drivers/mfd/rave-sp.c
parentmfd: rave-sp: Convert print_hex_dump() to print_hex_dump_debug() (diff)
downloadlinux-5112cab38c76c28f973def1a9c8b881f2dc81a48.tar.xz
linux-5112cab38c76c28f973def1a9c8b881f2dc81a48.zip
mfd: rave-sp: Check received frame length before accepting next byte
Check received frame length _before_ accepting next byte in order to avoid incorrectly rejecting payloads that are RAVE_SP_RX_BUFFER_SIZE long. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Tested-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd/rave-sp.c')
-rw-r--r--drivers/mfd/rave-sp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/mfd/rave-sp.c b/drivers/mfd/rave-sp.c
index b70416050a81..cb0cc9d509a0 100644
--- a/drivers/mfd/rave-sp.c
+++ b/drivers/mfd/rave-sp.c
@@ -546,8 +546,6 @@ static int rave_sp_receive_buf(struct serdev_device *serdev,
/* FALLTHROUGH */
case RAVE_SP_EXPECT_ESCAPED_DATA:
- deframer->data[deframer->length++] = byte;
-
if (deframer->length == sizeof(deframer->data)) {
dev_warn(dev, "Bad frame: Too long\n");
/*
@@ -562,6 +560,8 @@ static int rave_sp_receive_buf(struct serdev_device *serdev,
goto reset_framer;
}
+ deframer->data[deframer->length++] = byte;
+
/*
* We've extracted out special byte, now we
* can go back to regular data collecting