Commit 96a259de authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

[PATCH] USB: usb_get_string(), don't use bogus ids

This fixes a problem that's been around for some time:
usbcore will sometimes use un-initialized memory as if
it holds a valid language code.
parent 57b0031b
...@@ -986,7 +986,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) ...@@ -986,7 +986,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
if (err < 0) { if (err < 0) {
err("error getting string descriptor 0 (error=%d)", err); err("error getting string descriptor 0 (error=%d)", err);
goto errout; goto errout;
} else if (tbuf[0] < 4) { } else if (err < 4 || tbuf[0] < 4) {
err("string descriptor 0 too short"); err("string descriptor 0 too short");
err = -EINVAL; err = -EINVAL;
goto errout; goto errout;
......
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