summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2018-03-08 09:37:56 -0800
committerLee Jones <lee.jones@linaro.org>2018-05-16 09:21:48 +0100
commit5112cab38c76c28f973def1a9c8b881f2dc81a48 (patch)
tree14614d5732dc5bb98972a859afd30823e88ae695
parent44564bc3d999cb1febfdb6750e2059d2b308ce00 (diff)
downloadblackbird-obmc-linux-5112cab38c76c28f973def1a9c8b881f2dc81a48.tar.gz
blackbird-obmc-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>
-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
OpenPOWER on IntegriCloud