* re: Input: add driver for Elan I2C/SMbus touchpad
@ 2014-10-23 14:58 Dan Carpenter
2014-10-23 22:02 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2014-10-23 14:58 UTC (permalink / raw)
To: dusonlin; +Cc: linux-input
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Input: add driver for Elan I2C/SMbus touchpad
2014-10-23 14:58 Input: add driver for Elan I2C/SMbus touchpad Dan Carpenter
@ 2014-10-23 22:02 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2014-10-23 22:02 UTC (permalink / raw)
To: Dan Carpenter; +Cc: dusonlin, linux-input
Hi Dan,
On Thu, Oct 23, 2014 at 05:58:13PM +0300, Dan Carpenter wrote:
> 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:
Can you copy committer on such reports as well please?
>
> 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.
We should be checking sizeof(u16) here, I'll fix it up.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-10-23 22:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-23 14:58 Input: add driver for Elan I2C/SMbus touchpad Dan Carpenter
2014-10-23 22:02 ` Dmitry Torokhov
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).