From: Changming Liu <charley.ashbringer@gmail.com>
To: gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, thomas@winischhofer.net,
Changming Liu <charley.ashbringer@gmail.com>
Subject: [PATCH 4/4] USB: sisusbvga: change the buffers in sisusb_read_mem_bulk from char to u8
Date: Fri, 26 Jun 2020 15:34:17 -0400 [thread overview]
Message-ID: <1593200057-245-5-git-send-email-charley.ashbringer@gmail.com> (raw)
In-Reply-To: <1593200057-245-1-git-send-email-charley.ashbringer@gmail.com>
This patch changes the userbuffer,kernbuffer in the header of
sisusb_read_mem_bulk from char to u8 to avoid related UB.
Also a local buffer, buf, in sisusb_read_mem_bulk is changed
from char to u8.
Since sisusb_read_mem_bulk is called by sisusb_read_memory
sisusb_testreadwrite and sisusb_read, change their
passed-in parameters types from char to u8 accordingly.
Signed-off-by: Changming Liu <charley.ashbringer@gmail.com>
---
drivers/usb/misc/sisusbvga/sisusb.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index 86638c1..f1b46b5 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -1108,7 +1108,7 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,
ssize_t *bytes_read)
{
int ret = 0;
- char buf[4];
+ u8 buf[4];
u16 swap16;
u32 swap32;
@@ -1293,7 +1293,7 @@ int sisusb_copy_memory(struct sisusb_usb_data *sisusb, char *src,
}
#ifdef SISUSBENDIANTEST
-static int sisusb_read_memory(struct sisusb_usb_data *sisusb, char *dest,
+static int sisusb_read_memory(struct sisusb_usb_data *sisusb, u8 *dest,
u32 src, int length)
{
size_t dummy;
@@ -1308,7 +1308,7 @@ static int sisusb_read_memory(struct sisusb_usb_data *sisusb, char *dest,
static void sisusb_testreadwrite(struct sisusb_usb_data *sisusb)
{
static char srcbuffer[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 };
- char destbuffer[10];
+ u8 destbuffer[10];
int i, j;
sisusb_copy_memory(sisusb, srcbuffer, sisusb->vrambase, 7);
@@ -2561,7 +2561,7 @@ static ssize_t sisusb_read(struct file *file, char __user *buffer,
* Remember: Data delivered is never endian-corrected
*/
errno = sisusb_read_mem_bulk(sisusb, address,
- NULL, count, buffer, &bytes_read);
+ NULL, count, (u8 __user *)buffer, &bytes_read);
if (bytes_read)
errno = bytes_read;
@@ -2577,7 +2577,7 @@ static ssize_t sisusb_read(struct file *file, char __user *buffer,
* Remember: Data delivered is never endian-corrected
*/
errno = sisusb_read_mem_bulk(sisusb, address,
- NULL, count, buffer, &bytes_read);
+ NULL, count, (u8 __user *)buffer, &bytes_read);
if (bytes_read)
errno = bytes_read;
--
2.7.4
prev parent reply other threads:[~2020-06-26 19:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-26 19:34 [PATCH 0/4] USB: sisusbvga: cleaning up char buffers to u8 buffer Changming Liu
2020-06-26 19:34 ` [PATCH 1/4] USB: sisusbvga: change the char buffer from char to u8 for sisusb_write_mem_bulk and sisusb_send_bulk_msg Changming Liu
2020-06-27 11:28 ` Greg KH
2020-07-10 5:23 ` charley.ashbringer
2020-06-26 19:34 ` [PATCH 2/4] USB: sisusbvga: change the buffer members in sisusb_usb_data from char to u8 Changming Liu
2020-06-27 11:29 ` Greg KH
2020-06-26 19:34 ` [PATCH 3/4] USB: sisusbvga: change the buffer in sisusb_recv_bulk_msg " Changming Liu
2020-06-27 11:30 ` Greg KH
2020-06-26 19:34 ` Changming Liu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1593200057-245-5-git-send-email-charley.ashbringer@gmail.com \
--to=charley.ashbringer@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=thomas@winischhofer.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).