Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Aug 2009 11:16:00 GMT
From:      Patroklos Argyroudis <argp@census-labs.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/138389: NULL pointer dereference in usb_endpoint_foreach() in file sys/dev/usb/usb_device.c
Message-ID:  <200908311116.n7VBG0ml012620@www.freebsd.org>
Resent-Message-ID: <200908311120.n7VBK395084824@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         138389
>Category:       kern
>Synopsis:       NULL pointer dereference in usb_endpoint_foreach() in file sys/dev/usb/usb_device.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 31 11:20:03 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Patroklos Argyroudis
>Release:        8.0-CURRENT
>Organization:
census, inc
>Environment:
N/A
>Description:
There is a NULL pointer dereference in usb_endpoint_foreach() in file sys/dev/usb/usb_device.c at line 370.  The check against NULL at line 373 should be before the dereference of udev at line 370.
>How-To-Repeat:
N/A
>Fix:
Patch attached.

Patch attached with submission follows:

--- ./sys/dev/usb/usb_device.c.orig	2009-08-28 16:27:54.000000000 +0300
+++ ./sys/dev/usb/usb_device.c	2009-08-28 16:29:01.000000000 +0300
@@ -367,12 +367,14 @@
 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;


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908311116.n7VBG0ml012620>