linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: dusonlin@emc.com.tw
Cc: linux-input@vger.kernel.org
Subject: re: Input: add driver for Elan I2C/SMbus touchpad
Date: Thu, 23 Oct 2014 17:58:13 +0300	[thread overview]
Message-ID: <20141023145813.GA20197@mwanda> (raw)

Hello Duson Lin,

The patch 29fbd64b0fd2: "Input: add driver for Elan I2C/SMbus
touchpad" from Oct 3, 2014, leads to the following static checker
warning:

	drivers/input/mouse/elan_i2c_smbus.c:372 elan_smbus_prepare_fw_update()
	warn: sizeof(NUMBER)?

drivers/input/mouse/elan_i2c_smbus.c
   365                  /*
   366                   * Read back password to make sure we enabled flash
   367                   * successfully.
   368                   */
   369                  len = i2c_smbus_read_block_data(client,
   370                                                  ETP_SMBUS_IAP_PASSWORD_READ,
   371                                                  val);
   372                  if (len != sizeof(ETP_SMBUS_IAP_PASSWORD)) {
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sizeof(int) is 4.
val is a 3 byte array.
If we read 4 bytes then we are writing beyond the end of the val[]
array.

   373                          error = len < 0 ? len : -EIO;
   374                          dev_err(dev, "failed to read iap password: %d\n",
   375                                  error);
   376                          return error;
   377                  }
   378  
   379                  password = be16_to_cpup((__be16 *)val);
   380                  if (password != ETP_SMBUS_IAP_PASSWORD) {
   381                          dev_err(dev, "wrong iap password = 0x%X\n", password);
   382                          return -EIO;
   383                  }

regards,
dan carpenter

             reply	other threads:[~2014-10-23 14:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-23 14:58 Dan Carpenter [this message]
2014-10-23 22:02 ` Input: add driver for Elan I2C/SMbus touchpad Dmitry Torokhov

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=20141023145813.GA20197@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=dusonlin@emc.com.tw \
    --cc=linux-input@vger.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 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).