Skip to content

Commit f4228ac

Browse files
Kevin Groeneveldgregkh
authored andcommitted
usb: gadget: f_uac2: fix return value for UAC2_ATTRIBUTE_STRING store
commit 9499327 upstream. The configfs store callback should return the number of bytes consumed not the total number of bytes we actually stored. These could differ if for example the passed in string had a newline we did not store. If the returned value does not match the number of bytes written the writer might assume a failure or keep trying to write the remaining bytes. For example the following command will hang trying to write the final newline over and over again (tested on bash 2.05b): echo foo > function_name Fixes: 993a44f ("usb: gadget: f_uac2: allow changing interface name via configfs") Cc: stable <stable@kernel.org> Signed-off-by: Kevin Groeneveld <kgroeneveld@lenbrook.com> Link: https://lore.kernel.org/r/20241006232637.4267-1-kgroeneveld@lenbrook.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f828205 commit f4228ac

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/usb/gadget/function/f_uac2.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,7 +2055,7 @@ static ssize_t f_uac2_opts_##name##_store(struct config_item *item, \
20552055
const char *page, size_t len) \
20562056
{ \
20572057
struct f_uac2_opts *opts = to_f_uac2_opts(item); \
2058-
int ret = 0; \
2058+
int ret = len; \
20592059
\
20602060
mutex_lock(&opts->lock); \
20612061
if (opts->refcnt) { \
@@ -2066,8 +2066,8 @@ static ssize_t f_uac2_opts_##name##_store(struct config_item *item, \
20662066
if (len && page[len - 1] == '\n') \
20672067
len--; \
20682068
\
2069-
ret = scnprintf(opts->name, min(sizeof(opts->name), len + 1), \
2070-
"%s", page); \
2069+
scnprintf(opts->name, min(sizeof(opts->name), len + 1), \
2070+
"%s", page); \
20712071
\
20722072
end: \
20732073
mutex_unlock(&opts->lock); \

0 commit comments

Comments
 (0)