Skip to content

Commit 8bb233b

Browse files
author
Tzung-Bi Shih
committed
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: 04a8bdd ("platform/chrome: cros_ec_uart: Add transport layer") Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Tzung-Bi Shih <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Reviewed-by: Benson Leung <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 961a325 commit 8bb233b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/platform/chrome/cros_ec_uart.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,10 @@ static int cros_ec_uart_pkt_xfer(struct cros_ec_device *ec_dev,
149149
resp->status = 0;
150150

151151
ret = serdev_device_write_buf(serdev, ec_dev->dout, len);
152-
if (ret < len) {
152+
if (ret < 0 || ret < len) {
153153
dev_err(ec_dev->dev, "Unable to write data\n");
154-
ret = -EIO;
154+
if (ret >= 0)
155+
ret = -EIO;
155156
goto exit;
156157
}
157158

0 commit comments

Comments
 (0)