[PATCH 4.14 50/95] USB: gadget: u_ether: Fix a configfs return code
From: gregkh@linuxfoundation.org
Date: 2021-03-15 14:19:35
Also in:
lkml
From: gregkh@linuxfoundation.org
Date: 2021-03-15 14:19:35
Also in:
lkml
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
From: Dan Carpenter <redacted>
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 <redacted>
Acked-by: Lorenzo Colitti <redacted>
Signed-off-by: Dan Carpenter <redacted>
Link: https://lore.kernel.org/r/YCqZ3P53yyIg5cn7@mwanda (local)
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/gadget/function/u_ether_configfs.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
--- a/drivers/usb/gadget/function/u_ether_configfs.h
+++ b/drivers/usb/gadget/function/u_ether_configfs.h@@ -172,12 +172,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; \ } \