summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keeping <john@metanate.com>2017-11-27 18:15:40 +0000
committerDongwoo Lee <dwoo08.lee@samsung.com>2019-11-26 11:22:13 +0900
commit9d0a78bf3ce354c53c54b98204a3cd9f0ed90e8d (patch)
tree15dac88b524a0da9b9d7211385ab3008b996b87c
parent69b88967da8f7eb0e96825d640b0b78f66691741 (diff)
downloadlinux-4.9-exynos9110-9d0a78bf3ce354c53c54b98204a3cd9f0ed90e8d.tar.gz
linux-4.9-exynos9110-9d0a78bf3ce354c53c54b98204a3cd9f0ed90e8d.tar.bz2
linux-4.9-exynos9110-9d0a78bf3ce354c53c54b98204a3cd9f0ed90e8d.zip
usb: f_fs: Force Reserved1=1 in OS_DESC_EXT_COMPAT
commit a3acc696085e112733d191a77b106e67a4fa110b upstream. The specification says that the Reserved1 field in OS_DESC_EXT_COMPAT must have the value "1", but when this feature was first implemented we rejected any non-zero values. This was adjusted to accept all non-zero values (while now rejecting zero) in commit 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on reserved1 of OS_DESC_EXT_COMPAT"), but that breaks any userspace programs that worked previously by returning EINVAL when Reserved1 == 0 which was previously the only value that succeeded! If we just set the field to "1" ourselves, both old and new userspace programs continue to work correctly and, as a bonus, old programs are now compliant with the specification without having to fix anything themselves. Fixes: 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on reserved1 of OS_DESC_EXT_COMPAT") Signed-off-by: John Keeping <john@metanate.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> [dwoo08.lee: cherry-pick linux-4.9.y stable commit 112b8a8f558d to stablize f_fs] Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com> Change-Id: I00f7fce7bc2c5225c3f9ec00f30d1e4f4f0582de
-rw-r--r--drivers/usb/gadget/function/f_fs.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 2d3d22c837b2..76a994e07cb8 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -2263,9 +2263,18 @@ static int __ffs_data_do_os_desc(enum ffs_os_desc_type type,
int i;
if (len < sizeof(*d) ||
- d->bFirstInterfaceNumber >= ffs->interfaces_count ||
- d->Reserved1)
+ d->bFirstInterfaceNumber >= ffs->interfaces_count)
return -EINVAL;
+ if (d->Reserved1 != 1) {
+ /*
+ * According to the spec, Reserved1 must be set to 1
+ * but older kernels incorrectly rejected non-zero
+ * values. We fix it here to avoid returning EINVAL
+ * in response to values we used to accept.
+ */
+ pr_debug("usb_ext_compat_desc::Reserved1 forced to 1\n");
+ d->Reserved1 = 1;
+ }
for (i = 0; i < ARRAY_SIZE(d->Reserved2); ++i)
if (d->Reserved2[i])
return -EINVAL;