]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usb: gadget: f_fs: restore ffs_func_disable() functionality
authorTudor Ambarus <tudor.ambarus@linaro.org>
Fri, 2 Aug 2024 14:04:27 +0000 (14:04 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Aug 2024 13:34:28 +0000 (15:34 +0200)
commit0dbdb5ead3f4b17d48eea3ea75168f90491e2c37
tree681395c23cad596cb4c7d04287ba7398ca259217
parent3abba6e6f62fdfe07e533ad8dca7622e9ed13622
usb: gadget: f_fs: restore ffs_func_disable() functionality

commit 382b6eabb0316b7334d97afbdcf33a4e20b0ecd8 upstream.

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")
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>
drivers/usb/gadget/function/f_fs.c