Commit 6a448868 authored by Bjørn Mork's avatar Bjørn Mork Committed by Greg Kroah-Hartman

USB: cdc-wdm: fix wdm_find_device* return value

A logic error made the wdm_find_device* functions
return a bogus pointer into static data instead of
the intended NULL no matching device was found.

Cc: stable <stable@vger.kernel.org> # v3.4+
Cc: Oliver Neukum <oliver@neukum.org>
Signed-off-by: default avatarBjørn Mork <bjorn@mork.no>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f08dea73
...@@ -109,12 +109,14 @@ static struct usb_driver wdm_driver; ...@@ -109,12 +109,14 @@ static struct usb_driver wdm_driver;
/* return intfdata if we own the interface, else look up intf in the list */ /* return intfdata if we own the interface, else look up intf in the list */
static struct wdm_device *wdm_find_device(struct usb_interface *intf) static struct wdm_device *wdm_find_device(struct usb_interface *intf)
{ {
struct wdm_device *desc = NULL; struct wdm_device *desc;
spin_lock(&wdm_device_list_lock); spin_lock(&wdm_device_list_lock);
list_for_each_entry(desc, &wdm_device_list, device_list) list_for_each_entry(desc, &wdm_device_list, device_list)
if (desc->intf == intf) if (desc->intf == intf)
break; goto found;
desc = NULL;
found:
spin_unlock(&wdm_device_list_lock); spin_unlock(&wdm_device_list_lock);
return desc; return desc;
...@@ -122,12 +124,14 @@ static struct wdm_device *wdm_find_device(struct usb_interface *intf) ...@@ -122,12 +124,14 @@ static struct wdm_device *wdm_find_device(struct usb_interface *intf)
static struct wdm_device *wdm_find_device_by_minor(int minor) static struct wdm_device *wdm_find_device_by_minor(int minor)
{ {
struct wdm_device *desc = NULL; struct wdm_device *desc;
spin_lock(&wdm_device_list_lock); spin_lock(&wdm_device_list_lock);
list_for_each_entry(desc, &wdm_device_list, device_list) list_for_each_entry(desc, &wdm_device_list, device_list)
if (desc->intf->minor == minor) if (desc->intf->minor == minor)
break; goto found;
desc = NULL;
found:
spin_unlock(&wdm_device_list_lock); spin_unlock(&wdm_device_list_lock);
return desc; return desc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment