linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: nick.dyer@itdev.co.uk
Cc: linux-input@vger.kernel.org
Subject: re: Input: atmel_mxt_ts - read and report bootloader version
Date: Wed, 21 May 2014 15:26:24 +0300	[thread overview]
Message-ID: <20140521122624.GB23396@mwanda> (raw)

Hello Nick Dyer,

The patch e57a66aa8534: "Input: atmel_mxt_ts - read and report
bootloader version" from May 18, 2014, leads to the following static
checker warning:

	drivers/input/touchscreen/atmel_mxt_ts.c:437 mxt_get_bootloader_version()
	warn: signedness bug returning '(-5)'

drivers/input/touchscreen/atmel_mxt_ts.c
   429  static u8 mxt_get_bootloader_version(struct mxt_data *data, u8 val)
   430  {
   431          struct device *dev = &data->client->dev;
   432          u8 buf[3];
   433  
   434          if (val & MXT_BOOT_EXTENDED_ID) {
   435                  if (mxt_bootloader_read(data, &buf[0], 3) != 0) {
   436                          dev_err(dev, "%s: i2c failure\n", __func__);
   437                          return -EIO;
                                       ^^^^
This gets truncated into a number from 0-255 and anyway the caller
doesn't check for errors.

   438                  }
   439  
   440                  dev_dbg(dev, "Bootloader ID:%d Version:%d\n", buf[1], buf[2]);
   441  
   442                  return buf[0];
   443          } else {
   444                  dev_dbg(dev, "Bootloader ID:%d\n", val & MXT_BOOT_ID_MASK);
   445  
   446                  return val;
   447          }
   448  }

regards,
dan carpenter

             reply	other threads:[~2014-05-21 12:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-21 12:26 Dan Carpenter [this message]
2014-05-29 12:34 ` [PATCH] Input: atmel_mxt_ts - fix invalid return from mxt_get_bootloader_version nick.dyer

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=20140521122624.GB23396@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=linux-input@vger.kernel.org \
    --cc=nick.dyer@itdev.co.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).