USB: gadget: Fix a configfs return code
Subsystems (2)
PATCH 1/1 USB: gadget: 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")
Signed-off-by Dan Carpenter <[email protected]>
--- drivers/usb/gadget/function/u_ether_configfs.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/usb/gadget/function/u_ether_configfs.h +2 -3
@@ -182,12 +182,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; \ } \
Signature · 1 line
2.30.0
drivers/usb/gadget/function/u_ether_configfs.h out: \ · line 192
Quoted 13 lines · Dan Carpenter
{ \ struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \drivers/usb/gadget/function/u_ether_configfs.h +2
-3-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; \ } \
Acked-by Lorenzo Colitti <[email protected]>