Commit 8bb233b2 authored by Tzung-Bi Shih's avatar Tzung-Bi Shih

platform/chrome: cros_ec_uart: fix negative type promoted to high

serdev_device_write_buf() returns negative numbers on errors.  When
the return value compares to unsigned integer `len`, it promotes to
quite large positive number.

Fix it.

Fixes: 04a8bdd1 ("platform/chrome: cros_ec_uart: Add transport layer")
Reported-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarBenson Leung <bleung@chromium.org>
Link: https://lore.kernel.org/r/20230109081554.3792547-1-tzungbi@kernel.org
parent 961a325b
......@@ -149,9 +149,10 @@ static int cros_ec_uart_pkt_xfer(struct cros_ec_device *ec_dev,
resp->status = 0;
ret = serdev_device_write_buf(serdev, ec_dev->dout, len);
if (ret < len) {
if (ret < 0 || ret < len) {
dev_err(ec_dev->dev, "Unable to write data\n");
ret = -EIO;
if (ret >= 0)
ret = -EIO;
goto exit;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment