summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2021-02-15 18:57:16 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-03-17 19:06:29 +0300
commit50233f8220f030627d0e707b92666895902e0439 (patch)
treee7cd8b2111d3c30f76ddb562088b66ba2505d54f /drivers/usb
parent80091541a46b7d9cad70df974291dd544b837555 (diff)
downloadlinux-50233f8220f030627d0e707b92666895902e0439.tar.xz
USB: gadget: u_ether: Fix a configfs return code
commit 650bf52208d804ad5ee449c58102f8dc43175573 upstream. 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>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/function/u_ether_configfs.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/usb/gadget/function/u_ether_configfs.h b/drivers/usb/gadget/function/u_ether_configfs.h
index bd92b5703013..f982e18a5a78 100644
--- a/drivers/usb/gadget/function/u_ether_configfs.h
+++ b/drivers/usb/gadget/function/u_ether_configfs.h
@@ -169,12 +169,11 @@ out: \
size_t len) \
{ \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
- int ret; \
+ int ret = -EINVAL; \
u8 val; \
\
mutex_lock(&opts->lock); \
- ret = sscanf(page, "%02hhx", &val); \
- if (ret > 0) { \
+ if (sscanf(page, "%02hhx", &val) > 0) { \
opts->_n_ = val; \
ret = len; \
} \