Message ID | 1593200057-245-4-git-send-email-charley.ashbringer@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | USB: sisusbvga: cleaning up char buffers to u8 buffer | expand |
On Fri, Jun 26, 2020 at 03:34:16PM -0400, Changming Liu wrote: > This patch changes the userbuffer of sisusb_recv_bulk_msg from char to u8 > to avoid related UB. > > Also, for kernbuffer declared as void* in the function header, force cast > the passed-in parameters from char* to u8*. > > Signed-off-by: Changming Liu <charley.ashbringer@gmail.com> > --- > drivers/usb/misc/sisusbvga/sisusb.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c > index 8878c28..86638c1 100644 > --- a/drivers/usb/misc/sisusbvga/sisusb.c > +++ b/drivers/usb/misc/sisusbvga/sisusb.c > @@ -448,7 +448,7 @@ static int sisusb_send_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, > */ > > static int sisusb_recv_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, > - void *kernbuffer, char __user *userbuffer, ssize_t *bytes_read, > + void *kernbuffer, u8 __user *userbuffer, ssize_t *bytes_read, Same as before, I do not think you need to change these, do you? thanks, greg k-h
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index 8878c28..86638c1 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c @@ -448,7 +448,7 @@ static int sisusb_send_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, */ static int sisusb_recv_bulk_msg(struct sisusb_usb_data *sisusb, int ep, int len, - void *kernbuffer, char __user *userbuffer, ssize_t *bytes_read, + void *kernbuffer, u8 __user *userbuffer, ssize_t *bytes_read, unsigned int tflags) { int result = 0, retry, count = len; @@ -551,7 +551,7 @@ static int sisusb_send_packet(struct sisusb_usb_data *sisusb, int len, * return value and write it to packet->data */ ret = sisusb_recv_bulk_msg(sisusb, SISUSB_EP_GFX_IN, 4, - (char *)&tmp, NULL, &bytes_transferred, 0); + (u8 *)&tmp, NULL, &bytes_transferred, 0); packet->data = le32_to_cpu(tmp); } @@ -587,7 +587,7 @@ static int sisusb_send_bridge_packet(struct sisusb_usb_data *sisusb, int len, * return value and write it to packet->data */ ret = sisusb_recv_bulk_msg(sisusb, SISUSB_EP_BRIDGE_IN, 4, - (char *)&tmp, NULL, &bytes_transferred, 0); + (u8 *)&tmp, NULL, &bytes_transferred, 0); packet->data = le32_to_cpu(tmp); }
This patch changes the userbuffer of sisusb_recv_bulk_msg from char to u8 to avoid related UB. Also, for kernbuffer declared as void* in the function header, force cast the passed-in parameters from char* to u8*. Signed-off-by: Changming Liu <charley.ashbringer@gmail.com> --- drivers/usb/misc/sisusbvga/sisusb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)