Skip to content

Commit 382b6ea

Browse files
ambarusgregkh
authored andcommitted
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: 2f55055 ("usb: gadget: f_fs: Add the missing get_alt callback") Cc: stable <stable@kernel.org> Reported-by: William McVicker <willmcvicker@google.com> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org> Link: https://lore.kernel.org/r/20240802140428.2000312-2-tudor.ambarus@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7d5cbd7 commit 382b6ea

File tree

1 file changed

+3
-3
lines changed
  • drivers/usb/gadget/function

1 file changed

+3
-3
lines changed

drivers/usb/gadget/function/f_fs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3731,10 +3731,10 @@ static int ffs_func_set_alt(struct usb_function *f,
37313731
struct ffs_data *ffs = func->ffs;
37323732
int ret = 0, intf;
37333733

3734-
if (alt > MAX_ALT_SETTINGS)
3735-
return -EINVAL;
3736-
37373734
if (alt != (unsigned)-1) {
3735+
if (alt > MAX_ALT_SETTINGS)
3736+
return -EINVAL;
3737+
37383738
intf = ffs_func_revmap_intf(func, interface);
37393739
if (intf < 0)
37403740
return intf;

0 commit comments

Comments
 (0)