Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: gadget: u_ether: Fix a configfs return code

If the string is invalid, this should return -EINVAL instead of 0.

Fixes: 73517cf49bd4 ("usb: gadget: add RNDIS configfs options for class/subclass/protocol")
Cc: stable <stable@vger.kernel.org>
Acked-by: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YCqZ3P53yyIg5cn7@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Dan Carpenter and committed by
Greg Kroah-Hartman
650bf522 1edbff9c

+2 -3
+2 -3
drivers/usb/gadget/function/u_ether_configfs.h
··· 182 182 size_t len) \ 183 183 { \ 184 184 struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ 185 - int ret; \ 185 + int ret = -EINVAL; \ 186 186 u8 val; \ 187 187 \ 188 188 mutex_lock(&opts->lock); \ 189 - ret = sscanf(page, "%02hhx", &val); \ 190 - if (ret > 0) { \ 189 + if (sscanf(page, "%02hhx", &val) > 0) { \ 191 190 opts->_n_ = val; \ 192 191 ret = len; \ 193 192 } \