Skip to content

Commit b7af0bb

Browse files
Daniel Mackgregkh
authored andcommitted
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: Daniel Mack <daniel@caiaq.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 4c24b6d commit b7af0bb

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/usb/core/message.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -804,18 +804,16 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
804804
dev_err(&dev->dev,
805805
"string descriptor 0 read error: %d\n",
806806
err);
807-
goto errout;
808807
} else if (err < 4) {
809808
dev_err(&dev->dev, "string descriptor 0 too short\n");
810-
err = -EINVAL;
811-
goto errout;
812809
} else {
813-
dev->have_langid = 1;
814810
dev->string_langid = tbuf[2] | (tbuf[3] << 8);
815811
/* always use the first langid listed */
816812
dev_dbg(&dev->dev, "default language 0x%04x\n",
817813
dev->string_langid);
818814
}
815+
816+
dev->have_langid = 1;
819817
}
820818

821819
err = usb_string_sub(dev, dev->string_langid, index, tbuf);

0 commit comments

Comments
 (0)