Commit b7af0bb2 authored by Daniel Mack's avatar Daniel Mack Committed by Greg Kroah-Hartman

USB: allow malformed LANGID descriptors

When an USB hardware does not provide a valid LANGID, fall back to value
zero which is still a reasonable default for most devices.
Signed-off-by: default avatarDaniel Mack <daniel@caiaq.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 4c24b6d0
...@@ -804,18 +804,16 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) ...@@ -804,18 +804,16 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
dev_err(&dev->dev, dev_err(&dev->dev,
"string descriptor 0 read error: %d\n", "string descriptor 0 read error: %d\n",
err); err);
goto errout;
} else if (err < 4) { } else if (err < 4) {
dev_err(&dev->dev, "string descriptor 0 too short\n"); dev_err(&dev->dev, "string descriptor 0 too short\n");
err = -EINVAL;
goto errout;
} else { } else {
dev->have_langid = 1;
dev->string_langid = tbuf[2] | (tbuf[3] << 8); dev->string_langid = tbuf[2] | (tbuf[3] << 8);
/* always use the first langid listed */ /* always use the first langid listed */
dev_dbg(&dev->dev, "default language 0x%04x\n", dev_dbg(&dev->dev, "default language 0x%04x\n",
dev->string_langid); dev->string_langid);
} }
dev->have_langid = 1;
} }
err = usb_string_sub(dev, dev->string_langid, index, tbuf); err = usb_string_sub(dev, dev->string_langid, index, tbuf);
......
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