Skip to content

Commit

Permalink
mfd: rave-sp: Check received frame length before accepting next byte
Browse files Browse the repository at this point in the history
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 <[email protected]>
Tested-by: Lucas Stach <[email protected]>
Signed-off-by: Lee Jones <[email protected]>
  • Loading branch information
ndreys authored and Lee Jones committed May 16, 2018
1 parent 44564bc commit 5112cab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/mfd/rave-sp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
/*
Expand All @@ -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
Expand Down

0 comments on commit 5112cab

Please sign in to comment.