Re: [PATCH v2] HID: cp2112: fix I2C_SMBUS_BYTE write

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

 



On Tue, Jul 14, 2015 at 6:23 AM, Ellen Wang <ellen@xxxxxxxxxxxxxxxxxxx> wrote:
>
> When doing an I2C_SMBUS_BYTE write (one byte write, no address),
> the data to be written is in "command" not "data->byte".
>
> Signed-off-by: Ellen Wang <ellen@xxxxxxxxxxxxxxxxxxx>
> ---
> Forgot signed-off-by tag last time, sorry.
> ---
>  drivers/hid/hid-cp2112.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
> index a3703b8..7afc3fc 100644
> --- a/drivers/hid/hid-cp2112.c
> +++ b/drivers/hid/hid-cp2112.c
> @@ -606,7 +606,7 @@ static int cp2112_xfer(struct i2c_adapter *adap, u16 addr,
>                 if (I2C_SMBUS_READ == read_write)
>                         count = cp2112_read_req(buf, addr, read_length);
>                 else
> -                       count = cp2112_write_req(buf, addr, data->byte, NULL,
> +                       count = cp2112_write_req(buf, addr, command, NULL,
>                                                  0);
>                 break;
>         case I2C_SMBUS_BYTE_DATA:


Correct!

E.g. in drivers/i2c/i2c-core.c we have:

s32 i2c_smbus_write_byte(const struct i2c_client *client, u8 value)
{
       return i2c_smbus_xfer(client->adapter, client->addr, client->flags,
                             I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL);
}

that passes NULL for data, so data->byte will dereference the NULL ptr.
The value is passed in "command".

Jiri,
I agree with Ellen that this driver is not commonly used, so no rush
to push the fix upstream.
But the fix should be marked for stable.

If you need, you can add
Reviewed-by: Antonio Borneo <borneo.antonio@xxxxxxxxx>

BR
Antonio
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux