From: Dan Carpenter <error27@gmail.com>
To: Tzung-Bi Shih <tzungbi@kernel.org>
Cc: bleung@chromium.org, groeck@chromium.org,
chrome-platform@lists.linux.dev, markhas@chromium.org,
bhanumaiya@chromium.org
Subject: Re: [PATCH] platform/chrome: cros_ec_uart: fix negative type promoted to high
Date: Tue, 17 Jan 2023 11:19:04 +0300 [thread overview]
Message-ID: <Y8ZZ+MZvtkYR0aD2@kadam> (raw)
In-Reply-To: <Y8ZYeIev6SR2vMs6@google.com>
On Tue, Jan 17, 2023 at 04:12:40PM +0800, Tzung-Bi Shih wrote:
> On Mon, Jan 09, 2023 at 04:15:54PM +0800, Tzung-Bi Shih wrote:
> > 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>
> > ---
> > Reported in https://lore.kernel.org/chrome-platform/Y7fhw4S7Tb0GcHMF@kili/T/#u.
> >
> > drivers/platform/chrome/cros_ec_uart.c | 5 +++--
> > 1 file 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;
> > }
>
> Does this patch make sense to someone in the mailing list?
Yeah. It looks fine.
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
regards,
dan carpenter
next prev parent reply other threads:[~2023-01-17 8:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-09 8:15 [PATCH] platform/chrome: cros_ec_uart: fix negative type promoted to high Tzung-Bi Shih
2023-01-09 18:51 ` Mark Hasemeyer
2023-01-10 3:27 ` Tzung-Bi Shih
2023-01-17 8:12 ` Tzung-Bi Shih
2023-01-17 8:19 ` Dan Carpenter [this message]
2023-01-17 14:45 ` Benson Leung
2023-01-18 3:00 ` patchwork-bot+chrome-platform
2023-01-18 6:20 ` patchwork-bot+chrome-platform
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y8ZZ+MZvtkYR0aD2@kadam \
--to=error27@gmail.com \
--cc=bhanumaiya@chromium.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=markhas@chromium.org \
--cc=tzungbi@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.