Skip to content

Commit fea22e1

Browse files
rustylifegregkh
authored andcommitted
staging: wlan-ng: fix out of bounds read in prism2sta_probe_usb()
let's use usb_find_common_endpoints() to discover endpoints, it does all necessary checks for type and xfer direction remove memset() in hfa384x_create(), because we now assign endpoints in prism2sta_probe_usb() and because create_wlan() uses kzalloc() to allocate hfa384x struct before calling hfa384x_create() Fixes: faaff97 ("staging: wlan-ng: properly check endpoint types") Reported-and-tested-by: syzbot+22794221ab96b0bab53a@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=22794221ab96b0bab53a Signed-off-by: Rustam Kovhaev <rkovhaev@gmail.com> Cc: stable <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20200804145614.104320-1-rkovhaev@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b15b4da commit fea22e1

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

drivers/staging/wlan-ng/hfa384x_usb.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,8 @@ static void hfa384x_usb_defer(struct work_struct *data)
524524
*/
525525
void hfa384x_create(struct hfa384x *hw, struct usb_device *usb)
526526
{
527-
memset(hw, 0, sizeof(*hw));
528527
hw->usb = usb;
529528

530-
/* set up the endpoints */
531-
hw->endp_in = usb_rcvbulkpipe(usb, 1);
532-
hw->endp_out = usb_sndbulkpipe(usb, 2);
533-
534529
/* Set up the waitq */
535530
init_waitqueue_head(&hw->cmdq);
536531

drivers/staging/wlan-ng/prism2usb.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,14 @@ static int prism2sta_probe_usb(struct usb_interface *interface,
6161
const struct usb_device_id *id)
6262
{
6363
struct usb_device *dev;
64-
const struct usb_endpoint_descriptor *epd;
65-
const struct usb_host_interface *iface_desc = interface->cur_altsetting;
64+
struct usb_endpoint_descriptor *bulk_in, *bulk_out;
65+
struct usb_host_interface *iface_desc = interface->cur_altsetting;
6666
struct wlandevice *wlandev = NULL;
6767
struct hfa384x *hw = NULL;
6868
int result = 0;
6969

70-
if (iface_desc->desc.bNumEndpoints != 2) {
71-
result = -ENODEV;
72-
goto failed;
73-
}
74-
75-
result = -EINVAL;
76-
epd = &iface_desc->endpoint[1].desc;
77-
if (!usb_endpoint_is_bulk_in(epd))
78-
goto failed;
79-
epd = &iface_desc->endpoint[2].desc;
80-
if (!usb_endpoint_is_bulk_out(epd))
70+
result = usb_find_common_endpoints(iface_desc, &bulk_in, &bulk_out, NULL, NULL);
71+
if (result)
8172
goto failed;
8273

8374
dev = interface_to_usbdev(interface);
@@ -96,6 +87,8 @@ static int prism2sta_probe_usb(struct usb_interface *interface,
9687
}
9788

9889
/* Initialize the hw data */
90+
hw->endp_in = usb_rcvbulkpipe(dev, bulk_in->bEndpointAddress);
91+
hw->endp_out = usb_sndbulkpipe(dev, bulk_out->bEndpointAddress);
9992
hfa384x_create(hw, dev);
10093
hw->wlandev = wlandev;
10194

0 commit comments

Comments
 (0)