summaryrefslogtreecommitdiff
path: root/drivers/misc/cros_ec.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-01-16 14:52:24 -0700
committerSimon Glass <sjg@chromium.org>2021-01-30 14:25:41 -0700
commit698e30f7a862ae6eb4754ef0d42b8dc8cf416edd (patch)
treec7cf5a61e33bc8bde451fbab7930a2c7a773201a /drivers/misc/cros_ec.c
parent2525e53c2766a8731ebee9d13dd491a8ba0db2cb (diff)
downloadu-boot-698e30f7a862ae6eb4754ef0d42b8dc8cf416edd.tar.gz
cros_ec: Add run-time check for input buffer overflow
This should not happen in normal operation, but the EC might have a bug, so add a run-time check just in case. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/misc/cros_ec.c')
-rw-r--r--drivers/misc/cros_ec.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index ce5fa5bee3..e51ac87409 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -404,6 +404,8 @@ static int ec_command(struct udevice *dev, uint cmd, int cmd_version,
*/
if (din && in_buffer) {
assert(len <= din_len);
+ if (len > din_len)
+ return -ENOSPC;
memmove(din, in_buffer, len);
}
}