Skip to content

Commit

Permalink
USB: sisusbvga: Fix a potential UB casued by left shifting a negative…
Browse files Browse the repository at this point in the history
… value

The char buffer buf, receives data directly from user space,
so its content might be negative and its elements are left
shifted to form an unsigned integer.

Since left shifting a negative value is undefined behavior, thus
change the char to u8 to elimintate this UB.

Signed-off-by: Changming Liu <charley.ashbringer@gmail.com>
Link: https://lore.kernel.org/r/20200711043018.928-1-charley.ashbringer@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Lawliar authored and gregkh committed Jul 15, 2020
1 parent 48025b4 commit 2b53a19
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/usb/misc/sisusbvga/sisusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

/* if neither kernbuffer not userbuffer are given, assume
* data in obuf
Expand Down

0 comments on commit 2b53a19

Please sign in to comment.