From a9e267575ba23c863d20ec3725803e53e65914a0 Mon Sep 17 00:00:00 2001 From: Andrew Thompson Date: Mon, 28 Sep 2009 07:39:51 +0000 Subject: [PATCH] Fix NULL-pointer dereference in usb_endpoint_foreach(). PR: usb/138389 Submitted by: Patroklos Argyroudis at census, inc --- sys/dev/usb/usb_device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c index d286db08b481..ea864f4287db 100644 --- a/sys/dev/usb/usb_device.c +++ b/sys/dev/usb/usb_device.c @@ -367,12 +367,14 @@ usb_init_endpoint(struct usb_device *udev, uint8_t iface_index, struct usb_endpoint * usb_endpoint_foreach(struct usb_device *udev, struct usb_endpoint *ep) { - struct usb_endpoint *ep_end = udev->endpoints + udev->endpoints_max; + struct usb_endpoint *ep_end; /* be NULL safe */ if (udev == NULL) return (NULL); + ep_end = udev->endpoints + udev->endpoints_max; + /* get next endpoint */ if (ep == NULL) ep = udev->endpoints;