Re: [PATCH 4/6] USB: serial: ftdi_sio: only allow valid event_char values

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

 



On Tue, Feb 28, 2017 at 12:51:26PM +0000, Ian Abbott wrote:
> The "event_char" device attribute value, when written, is interpreted as
> an enable bit in bit 8, and an "event character" in bits 7 to 0.  Return
> an error for out-of-range values.
> 
> Signed-off-by: Ian Abbott <abbotti@xxxxxxxxx>
> ---
>  drivers/usb/serial/ftdi_sio.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
> index 2da99875cecb..2662fc3b49c5 100644
> --- a/drivers/usb/serial/ftdi_sio.c
> +++ b/drivers/usb/serial/ftdi_sio.c
> @@ -1738,6 +1738,9 @@ static ssize_t store_event_char(struct device *dev,
>  	int v = simple_strtoul(valbuf, NULL, 10);
>  	int rv;
>  
> +	if (v < 0 || v >= 0x200)
> +		return -EINVAL;
> +

v < 0 is always false here due to the unsigned simple_strtoul above,
which continues to accept negative values after this change.

It may be better to combine this with the kstrtouint conversion.

>  	dev_dbg(&port->dev, "%s: setting event char = %i\n", __func__, v);
>  
>  	rv = usb_control_msg(udev,

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" 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]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux