[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240802140428.2000312-2-tudor.ambarus@linaro.org>
Date: Fri, 2 Aug 2024 14:04:27 +0000
From: Tudor Ambarus <tudor.ambarus@...aro.org>
To: gregkh@...uxfoundation.org,
hgajjar@...adit-jv.com,
willmcvicker@...gle.com
Cc: paul@...pouillou.net,
brauner@...nel.org,
christian.koenig@....com,
jlayton@...nel.org,
kees@...nel.org,
linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org,
andre.draszik@...aro.org,
peter.griffin@...aro.org,
Tudor Ambarus <tudor.ambarus@...aro.org>
Subject: [PATCH 1/2] usb: gadget: f_fs: restore ffs_func_disable() functionality
The blamed commit made ffs_func_disable() always return -EINVAL as the
method calls ffs_func_set_alt() with the ``alt`` argument being
``(unsigned)-1``, which is always greater than MAX_ALT_SETTINGS.
Use the MAX_ALT_SETTINGS check just in the f->set_alt() code path,
f->disable() doesn't care about the ``alt`` parameter.
Make a surgical fix, but really the f->disable() code shall be pulled
out from ffs_func_set_alt(), the code will become clearer. A patch will
follow.
Note that ffs_func_disable() always returning -EINVAL made pixel6 crash
on USB disconnect.
Fixes: 2f550553e23c ("usb: gadget: f_fs: Add the missing get_alt callback")
Reported-by: William McVicker <willmcvicker@...gle.com>
Signed-off-by: Tudor Ambarus <tudor.ambarus@...aro.org>
---
drivers/usb/gadget/function/f_fs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index d8b096859337..0bfed1741b3e 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -3731,10 +3731,10 @@ static int ffs_func_set_alt(struct usb_function *f,
struct ffs_data *ffs = func->ffs;
int ret = 0, intf;
- if (alt > MAX_ALT_SETTINGS)
- return -EINVAL;
-
if (alt != (unsigned)-1) {
+ if (alt > MAX_ALT_SETTINGS)
+ return -EINVAL;
+
intf = ffs_func_revmap_intf(func, interface);
if (intf < 0)
return intf;
--
2.46.0.rc2.264.g509ed76dc8-goog
Powered by blists - more mailing lists