re: Input: add driver for Elan I2C/SMbus touchpad

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux