diff options
author | Tzung-Bi Shih <tzungbi@kernel.org> | 2023-01-09 09:15:54 +0100 |
---|---|---|
committer | Tzung-Bi Shih <tzungbi@kernel.org> | 2023-01-18 03:57:51 +0100 |
commit | 8bb233b27fb7c11deefbe2318e75490b22cf3d1a (patch) | |
tree | ef53cb478710d97637f4f22396f9bfd7800e89e4 /drivers/platform | |
parent | platform/chrome: cros_ec: Use per-device lockdep key (diff) | |
download | linux-8bb233b27fb7c11deefbe2318e75490b22cf3d1a.tar.xz linux-8bb233b27fb7c11deefbe2318e75490b22cf3d1a.zip |
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: 04a8bdd135cc ("platform/chrome: cros_ec_uart: Add transport layer")
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
Link: https://lore.kernel.org/r/20230109081554.3792547-1-tzungbi@kernel.org
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/chrome/cros_ec_uart.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/platform/chrome/cros_ec_uart.c b/drivers/platform/chrome/cros_ec_uart.c index 6916069f1599..788246559bbb 100644 --- a/drivers/platform/chrome/cros_ec_uart.c +++ b/drivers/platform/chrome/cros_ec_uart.c @@ -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; } |