Re: [PATCH] USB: sisusbvga: Fix left shifting a possible negative value

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

 



On Wed, May 20, 2020 at 06:06:50PM +0000, Changming Liu wrote:
> The char buffer buf, accepts user data which might be negative value and
> the content is left shifted to form an unsigned integer.
> 
> Since left shifting a negative value is undefined behavior, thus change
> the char to u8 to fix this
> 
> Signed-off-by: Changming Liu <liu.changm@xxxxxxxxxxxxxxxx>
> ---
>  drivers/usb/misc/sisusbvga/sisusb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
> index fc8a5da4a07c..0734e6dd9386 100644
> --- a/drivers/usb/misc/sisusbvga/sisusb.c
> +++ b/drivers/usb/misc/sisusbvga/sisusb.c
> @@ -761,7 +761,7 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,
>         u8   swap8, fromkern = kernbuffer ? 1 : 0;
>         u16  swap16;
>         u32  swap32, flag = (length >> 28) & 1;
> -       char buf[4];
> +       u8 buf[4];

Do we also need to change the kernbuffer variable from char* to be u8*
as the same time to solve the same potential issue?

thanks,

greg k-h



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux