On Mon, Aug 26, 2024 at 08:29:57PM +0800, Edward Adam Davis wrote: > ath6kl_usb_submit_ctrl_in() did not take into account the situation where > the length of the data read from the device is not equal to the len, and > such missing judgments will result in subsequent code using incorrect data. > > usb_control_msg_recv() handles the abnormal length of the returned data, > so using it directly. > > Suggested-by: Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> > Signed-off-by: Edward Adam Davis <eadavis@xxxxxx> > --- > drivers/net/wireless/ath/ath6kl/usb.c | 39 +++------------------------ > 1 file changed, 3 insertions(+), 36 deletions(-) > > diff --git a/drivers/net/wireless/ath/ath6kl/usb.c b/drivers/net/wireless/ath/ath6kl/usb.c > index 0458b5a078e1..b1fc66d823b8 100644 > --- a/drivers/net/wireless/ath/ath6kl/usb.c > +++ b/drivers/net/wireless/ath/ath6kl/usb.c > @@ -901,40 +901,6 @@ static int ath6kl_usb_submit_ctrl_out(struct ath6kl_usb *ar_usb, > return 0; > } > > -static int ath6kl_usb_submit_ctrl_in(struct ath6kl_usb *ar_usb, > - u8 req, u16 value, u16 index, void *data, > - u32 size) > -{ > - u8 *buf = NULL; > - int ret; > - > - if (size > 0) { > - buf = kmalloc(size, GFP_KERNEL); > - if (buf == NULL) > - return -ENOMEM; > - } > - > - /* note: if successful returns number of bytes transfered */ > - ret = usb_control_msg(ar_usb->udev, > - usb_rcvctrlpipe(ar_usb->udev, 0), > - req, > - USB_DIR_IN | USB_TYPE_VENDOR | > - USB_RECIP_DEVICE, value, index, buf, > - size, 2000); > - > - if (ret < 0) { > - ath6kl_warn("Failed to read usb control message: %d\n", ret); > - kfree(buf); > - return ret; > - } > - > - memcpy((u8 *) data, buf, size); > - > - kfree(buf); > - > - return 0; > -} > - > static int ath6kl_usb_ctrl_msg_exchange(struct ath6kl_usb *ar_usb, > u8 req_val, u8 *req_buf, u32 req_len, > u8 resp_val, u8 *resp_buf, u32 *resp_len) > @@ -954,8 +920,9 @@ static int ath6kl_usb_ctrl_msg_exchange(struct ath6kl_usb *ar_usb, > } > > /* get response */ > - ret = ath6kl_usb_submit_ctrl_in(ar_usb, resp_val, 0, 0, > - resp_buf, *resp_len); > + ret = usb_control_msg_recv(ar_usb->udev, 0, resp_val, > + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, > + 0, 0, resp_buf, *resp_len, 2000, GFP_KERNEL); You didn't run checkpatch on this :(