Message ID | 20210515115715.314138-1-chengzhihao1@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] usb: xhci: Check the return value from sg_pcopy_from_buffer | expand |
On Sat, May 15, 2021 at 07:57:15PM +0800, Zhihao Cheng wrote: > Fix the following gcc warning: > > drivers/usb/host/xhci.c:1349:15: warning: variable ‘len’ set but not > used [-Wunused-but-set-variable ] > > Reported-by: Hulk Robot <hulkci@huawei.com> > Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> > --- > drivers/usb/host/xhci.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c > index ca9385d22f68..08290698b939 100644 > --- a/drivers/usb/host/xhci.c > +++ b/drivers/usb/host/xhci.c > @@ -1361,11 +1361,15 @@ static void xhci_unmap_temp_buf(struct usb_hcd *hcd, struct urb *urb) > urb->transfer_buffer_length, > dir); > > - if (usb_urb_dir_in(urb)) > + if (usb_urb_dir_in(urb)) { > len = sg_pcopy_from_buffer(urb->sg, urb->num_sgs, > urb->transfer_buffer, > buf_len, > 0); > + if (len != buf_len) > + xhci_warn(hcd_to_xhci(hcd), "WARN Wrong transfer buffer read length: %u != %u\n", > + len, buf_len); So you complain to the user and then don't do anything else? that feels very wrong, who is going to address the user complaints that this change will cause? greg k-h
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index ca9385d22f68..08290698b939 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1361,11 +1361,15 @@ static void xhci_unmap_temp_buf(struct usb_hcd *hcd, struct urb *urb) urb->transfer_buffer_length, dir); - if (usb_urb_dir_in(urb)) + if (usb_urb_dir_in(urb)) { len = sg_pcopy_from_buffer(urb->sg, urb->num_sgs, urb->transfer_buffer, buf_len, 0); + if (len != buf_len) + xhci_warn(hcd_to_xhci(hcd), "WARN Wrong transfer buffer read length: %u != %u\n", + len, buf_len); + } urb->transfer_flags &= ~URB_DMA_MAP_SINGLE; kfree(urb->transfer_buffer);
Fix the following gcc warning: drivers/usb/host/xhci.c:1349:15: warning: variable ‘len’ set but not used [-Wunused-but-set-variable ] Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> --- drivers/usb/host/xhci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)