All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: gadget: Fix a configfs return code
@ 2021-02-15 15:57 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2021-02-15 15:57 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Greg Kroah-Hartman, Dan Carpenter, Nishad Kamdar,
	Lorenzo Colitti, David Lechner, linux-usb, linux-kernel,
	kernel-janitors

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 <dan.carpenter@oracle.com>
---
 drivers/usb/gadget/function/u_ether_configfs.h | 5 ++---
 1 file 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 3dfb460908fa..f558c3139ebe 100644
--- a/drivers/usb/gadget/function/u_ether_configfs.h
+++ b/drivers/usb/gadget/function/u_ether_configfs.h
@@ -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;					\
 		}							\
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] USB: gadget: Fix a configfs return code
@ 2021-02-15 15:57 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2021-02-15 15:57 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Greg Kroah-Hartman, Dan Carpenter, Nishad Kamdar,
	Lorenzo Colitti, David Lechner, linux-usb, linux-kernel,
	kernel-janitors

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 <dan.carpenter@oracle.com>
---
 drivers/usb/gadget/function/u_ether_configfs.h | 5 ++---
 1 file 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 3dfb460908fa..f558c3139ebe 100644
--- a/drivers/usb/gadget/function/u_ether_configfs.h
+++ b/drivers/usb/gadget/function/u_ether_configfs.h
@@ -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;					\
 		}							\
-- 
2.30.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] USB: gadget: Fix a configfs return code
  2021-02-15 15:57 ` Dan Carpenter
@ 2021-02-16  1:23   ` Lorenzo Colitti
  -1 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Colitti @ 2021-02-16  1:23 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Felipe Balbi, Greg Kroah-Hartman, Nishad Kamdar, David Lechner,
	linux-usb, lkml, kernel-janitors

On Tue, Feb 16, 2021 at 12:57 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>         {                                                               \
>                 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;                                      \
>                 }                                                       \

Acked-by: Lorenzo Colitti <lorenzo@google.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] USB: gadget: Fix a configfs return code
@ 2021-02-16  1:23   ` Lorenzo Colitti
  0 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Colitti @ 2021-02-16  1:23 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Felipe Balbi, Greg Kroah-Hartman, Nishad Kamdar, David Lechner,
	linux-usb, lkml, kernel-janitors

On Tue, Feb 16, 2021 at 12:57 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>         {                                                               \
>                 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;                                      \
>                 }                                                       \

Acked-by: Lorenzo Colitti <lorenzo@google.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-16  1:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-15 15:57 [PATCH] USB: gadget: Fix a configfs return code Dan Carpenter
2021-02-15 15:57 ` Dan Carpenter
2021-02-16  1:23 ` Lorenzo Colitti
2021-02-16  1:23   ` Lorenzo Colitti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.