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>
This commit is contained in:
Simon Glass 2021-01-16 14:52:24 -07:00
parent 2525e53c27
commit 698e30f7a8

View File

@ -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);
}
}