Skip to content

Commit

Permalink
USB: gadget: u_ether: Fix a configfs return code
Browse files Browse the repository at this point in the history
commit 650bf52 upstream.

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

Fixes: 73517cf ("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>
  • Loading branch information
Dan Carpenter authored and gregkh committed Mar 17, 2021
1 parent 0ae3101 commit ec7b0ac
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/usb/gadget/function/u_ether_configfs.h
Expand Up @@ -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; \
} \
Expand Down

0 comments on commit ec7b0ac

Please sign in to comment.