All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: u_serial: fix coverity warning: negative index at array
@ 2020-05-14  8:05 ` Macpaul Lin
  0 siblings, 0 replies; 9+ messages in thread
From: Macpaul Lin @ 2020-05-14  8:05 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Matthias Brugger,
	Michał Mirosław, Sergey Organov, Macpaul Lin,
	linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Mediatek WSD Upstream, Macpaul Lin, Stan Lu

This issue has been reported by coverity scanner.
Replace "int portnum" by "unsigned int", this void negative index at
array.

Signed-off-by: Stan Lu <stan.lu@mediatek.com>
Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
---
 drivers/usb/gadget/function/u_serial.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 8167d37..53951f2 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -587,7 +587,7 @@ static int gs_start_io(struct gs_port *port)
  */
 static int gs_open(struct tty_struct *tty, struct file *file)
 {
-	int		port_num = tty->index;
+	unsigned int	port_num = tty->index;
 	struct gs_port	*port;
 	int		status = 0;
 
@@ -1211,7 +1211,7 @@ int gserial_alloc_line_no_console(unsigned char *line_num)
 	struct gs_port			*port;
 	struct device			*tty_dev;
 	int				ret;
-	int				port_num;
+	unsigned int			port_num;
 
 	coding.dwDTERate = cpu_to_le32(9600);
 	coding.bCharFormat = 8;
-- 
1.7.9.5

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

* [PATCH] usb: gadget: u_serial: fix coverity warning: negative index at array
@ 2020-05-14  8:05 ` Macpaul Lin
  0 siblings, 0 replies; 9+ messages in thread
From: Macpaul Lin @ 2020-05-14  8:05 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Matthias Brugger,
	Michał Mirosław, Sergey Organov, Macpaul Lin,
	linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Stan Lu, Macpaul Lin, Mediatek WSD Upstream

This issue has been reported by coverity scanner.
Replace "int portnum" by "unsigned int", this void negative index at
array.

Signed-off-by: Stan Lu <stan.lu@mediatek.com>
Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
---
 drivers/usb/gadget/function/u_serial.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 8167d37..53951f2 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -587,7 +587,7 @@ static int gs_start_io(struct gs_port *port)
  */
 static int gs_open(struct tty_struct *tty, struct file *file)
 {
-	int		port_num = tty->index;
+	unsigned int	port_num = tty->index;
 	struct gs_port	*port;
 	int		status = 0;
 
@@ -1211,7 +1211,7 @@ int gserial_alloc_line_no_console(unsigned char *line_num)
 	struct gs_port			*port;
 	struct device			*tty_dev;
 	int				ret;
-	int				port_num;
+	unsigned int			port_num;
 
 	coding.dwDTERate = cpu_to_le32(9600);
 	coding.bCharFormat = 8;
-- 
1.7.9.5
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH] usb: gadget: u_serial: fix coverity warning: negative index at array
@ 2020-05-14  8:05 ` Macpaul Lin
  0 siblings, 0 replies; 9+ messages in thread
From: Macpaul Lin @ 2020-05-14  8:05 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Matthias Brugger,
	Michał Mirosław, Sergey Organov, Macpaul Lin,
	linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Stan Lu, Macpaul Lin, Mediatek WSD Upstream

This issue has been reported by coverity scanner.
Replace "int portnum" by "unsigned int", this void negative index at
array.

Signed-off-by: Stan Lu <stan.lu@mediatek.com>
Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
---
 drivers/usb/gadget/function/u_serial.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 8167d37..53951f2 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -587,7 +587,7 @@ static int gs_start_io(struct gs_port *port)
  */
 static int gs_open(struct tty_struct *tty, struct file *file)
 {
-	int		port_num = tty->index;
+	unsigned int	port_num = tty->index;
 	struct gs_port	*port;
 	int		status = 0;
 
@@ -1211,7 +1211,7 @@ int gserial_alloc_line_no_console(unsigned char *line_num)
 	struct gs_port			*port;
 	struct device			*tty_dev;
 	int				ret;
-	int				port_num;
+	unsigned int			port_num;
 
 	coding.dwDTERate = cpu_to_le32(9600);
 	coding.bCharFormat = 8;
-- 
1.7.9.5
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] usb: gadget: u_serial: fix coverity warning: negative index at array
  2020-05-14  8:05 ` Macpaul Lin
  (?)
@ 2020-05-14  9:38   ` Felipe Balbi
  -1 siblings, 0 replies; 9+ messages in thread
From: Felipe Balbi @ 2020-05-14  9:38 UTC (permalink / raw)
  To: Macpaul Lin, Greg Kroah-Hartman, Matthias Brugger,
	Michał Mirosław, Sergey Organov, Macpaul Lin,
	linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Mediatek WSD Upstream, Macpaul Lin, Stan Lu

[-- Attachment #1: Type: text/plain, Size: 919 bytes --]

Macpaul Lin <macpaul.lin@mediatek.com> writes:

> This issue has been reported by coverity scanner.
> Replace "int portnum" by "unsigned int", this void negative index at
> array.
>
> Signed-off-by: Stan Lu <stan.lu@mediatek.com>
> Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>

please rebase on testing/fixes

error: patch failed: drivers/usb/gadget/function/u_serial.c:587
error: drivers/usb/gadget/function/u_serial.c: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: usb: gadget: u_serial: fix coverity warning: negative index at array
Patch failed at 0001 usb: gadget: u_serial: fix coverity warning: negative index at array
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: [PATCH] usb: gadget: u_serial: fix coverity warning: negative index at array
@ 2020-05-14  9:38   ` Felipe Balbi
  0 siblings, 0 replies; 9+ messages in thread
From: Felipe Balbi @ 2020-05-14  9:38 UTC (permalink / raw)
  To: Macpaul Lin, Greg Kroah-Hartman, Matthias Brugger,
	Michał Mirosław, Sergey Organov, Macpaul Lin,
	linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Stan Lu, Macpaul Lin, Mediatek WSD Upstream


[-- Attachment #1.1: Type: text/plain, Size: 919 bytes --]

Macpaul Lin <macpaul.lin@mediatek.com> writes:

> This issue has been reported by coverity scanner.
> Replace "int portnum" by "unsigned int", this void negative index at
> array.
>
> Signed-off-by: Stan Lu <stan.lu@mediatek.com>
> Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>

please rebase on testing/fixes

error: patch failed: drivers/usb/gadget/function/u_serial.c:587
error: drivers/usb/gadget/function/u_serial.c: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: usb: gadget: u_serial: fix coverity warning: negative index at array
Patch failed at 0001 usb: gadget: u_serial: fix coverity warning: negative index at array
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

-- 
balbi

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH] usb: gadget: u_serial: fix coverity warning: negative index at array
@ 2020-05-14  9:38   ` Felipe Balbi
  0 siblings, 0 replies; 9+ messages in thread
From: Felipe Balbi @ 2020-05-14  9:38 UTC (permalink / raw)
  To: Macpaul Lin, Greg Kroah-Hartman, Matthias Brugger,
	Michał Mirosław, Sergey Organov, Macpaul Lin,
	linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek
  Cc: Stan Lu, Macpaul Lin, Mediatek WSD Upstream


[-- Attachment #1.1: Type: text/plain, Size: 919 bytes --]

Macpaul Lin <macpaul.lin@mediatek.com> writes:

> This issue has been reported by coverity scanner.
> Replace "int portnum" by "unsigned int", this void negative index at
> array.
>
> Signed-off-by: Stan Lu <stan.lu@mediatek.com>
> Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>

please rebase on testing/fixes

error: patch failed: drivers/usb/gadget/function/u_serial.c:587
error: drivers/usb/gadget/function/u_serial.c: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: usb: gadget: u_serial: fix coverity warning: negative index at array
Patch failed at 0001 usb: gadget: u_serial: fix coverity warning: negative index at array
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

-- 
balbi

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] usb: gadget: u_serial: fix coverity warning: negative index at array
  2020-05-14  8:05 ` Macpaul Lin
  (?)
@ 2020-05-14 14:22   ` Alan Stern
  -1 siblings, 0 replies; 9+ messages in thread
From: Alan Stern @ 2020-05-14 14:22 UTC (permalink / raw)
  To: Macpaul Lin
  Cc: Felipe Balbi, Greg Kroah-Hartman, Matthias Brugger,
	Michał Mirosław, Sergey Organov, linux-usb,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Mediatek WSD Upstream, Macpaul Lin, Stan Lu

On Thu, May 14, 2020 at 04:05:00PM +0800, Macpaul Lin wrote:
> This issue has been reported by coverity scanner.
> Replace "int portnum" by "unsigned int", this void negative index at
> array.

Can you please explain this more fully?  Why does coverity think the 
code might use a negative array index?  Is there some possibility that 
the portnum value might actually be negative?

It's noticeable that your patch doesn't actually change any values, only 
the type.  This means that if the code was buggy before, it's still 
buggy.  Alternatively, if the code wasn't buggy before then coverity got 
a false positive, so no change should be needed.

Alan Stern

> Signed-off-by: Stan Lu <stan.lu@mediatek.com>
> Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
> ---
>  drivers/usb/gadget/function/u_serial.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
> index 8167d37..53951f2 100644
> --- a/drivers/usb/gadget/function/u_serial.c
> +++ b/drivers/usb/gadget/function/u_serial.c
> @@ -587,7 +587,7 @@ static int gs_start_io(struct gs_port *port)
>   */
>  static int gs_open(struct tty_struct *tty, struct file *file)
>  {
> -	int		port_num = tty->index;
> +	unsigned int	port_num = tty->index;
>  	struct gs_port	*port;
>  	int		status = 0;
>  
> @@ -1211,7 +1211,7 @@ int gserial_alloc_line_no_console(unsigned char *line_num)
>  	struct gs_port			*port;
>  	struct device			*tty_dev;
>  	int				ret;
> -	int				port_num;
> +	unsigned int			port_num;
>  
>  	coding.dwDTERate = cpu_to_le32(9600);
>  	coding.bCharFormat = 8;
> -- 
> 1.7.9.5

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

* Re: [PATCH] usb: gadget: u_serial: fix coverity warning: negative index at array
@ 2020-05-14 14:22   ` Alan Stern
  0 siblings, 0 replies; 9+ messages in thread
From: Alan Stern @ 2020-05-14 14:22 UTC (permalink / raw)
  To: Macpaul Lin
  Cc: Stan Lu, Felipe Balbi, Mediatek WSD Upstream, Greg Kroah-Hartman,
	linux-usb, linux-kernel, Michał Mirosław,
	Sergey Organov, Matthias Brugger, linux-mediatek, Macpaul Lin,
	linux-arm-kernel

On Thu, May 14, 2020 at 04:05:00PM +0800, Macpaul Lin wrote:
> This issue has been reported by coverity scanner.
> Replace "int portnum" by "unsigned int", this void negative index at
> array.

Can you please explain this more fully?  Why does coverity think the 
code might use a negative array index?  Is there some possibility that 
the portnum value might actually be negative?

It's noticeable that your patch doesn't actually change any values, only 
the type.  This means that if the code was buggy before, it's still 
buggy.  Alternatively, if the code wasn't buggy before then coverity got 
a false positive, so no change should be needed.

Alan Stern

> Signed-off-by: Stan Lu <stan.lu@mediatek.com>
> Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
> ---
>  drivers/usb/gadget/function/u_serial.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
> index 8167d37..53951f2 100644
> --- a/drivers/usb/gadget/function/u_serial.c
> +++ b/drivers/usb/gadget/function/u_serial.c
> @@ -587,7 +587,7 @@ static int gs_start_io(struct gs_port *port)
>   */
>  static int gs_open(struct tty_struct *tty, struct file *file)
>  {
> -	int		port_num = tty->index;
> +	unsigned int	port_num = tty->index;
>  	struct gs_port	*port;
>  	int		status = 0;
>  
> @@ -1211,7 +1211,7 @@ int gserial_alloc_line_no_console(unsigned char *line_num)
>  	struct gs_port			*port;
>  	struct device			*tty_dev;
>  	int				ret;
> -	int				port_num;
> +	unsigned int			port_num;
>  
>  	coding.dwDTERate = cpu_to_le32(9600);
>  	coding.bCharFormat = 8;
> -- 
> 1.7.9.5

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH] usb: gadget: u_serial: fix coverity warning: negative index at array
@ 2020-05-14 14:22   ` Alan Stern
  0 siblings, 0 replies; 9+ messages in thread
From: Alan Stern @ 2020-05-14 14:22 UTC (permalink / raw)
  To: Macpaul Lin
  Cc: Stan Lu, Felipe Balbi, Mediatek WSD Upstream, Greg Kroah-Hartman,
	linux-usb, linux-kernel, Michał Mirosław,
	Sergey Organov, Matthias Brugger, linux-mediatek, Macpaul Lin,
	linux-arm-kernel

On Thu, May 14, 2020 at 04:05:00PM +0800, Macpaul Lin wrote:
> This issue has been reported by coverity scanner.
> Replace "int portnum" by "unsigned int", this void negative index at
> array.

Can you please explain this more fully?  Why does coverity think the 
code might use a negative array index?  Is there some possibility that 
the portnum value might actually be negative?

It's noticeable that your patch doesn't actually change any values, only 
the type.  This means that if the code was buggy before, it's still 
buggy.  Alternatively, if the code wasn't buggy before then coverity got 
a false positive, so no change should be needed.

Alan Stern

> Signed-off-by: Stan Lu <stan.lu@mediatek.com>
> Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
> ---
>  drivers/usb/gadget/function/u_serial.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
> index 8167d37..53951f2 100644
> --- a/drivers/usb/gadget/function/u_serial.c
> +++ b/drivers/usb/gadget/function/u_serial.c
> @@ -587,7 +587,7 @@ static int gs_start_io(struct gs_port *port)
>   */
>  static int gs_open(struct tty_struct *tty, struct file *file)
>  {
> -	int		port_num = tty->index;
> +	unsigned int	port_num = tty->index;
>  	struct gs_port	*port;
>  	int		status = 0;
>  
> @@ -1211,7 +1211,7 @@ int gserial_alloc_line_no_console(unsigned char *line_num)
>  	struct gs_port			*port;
>  	struct device			*tty_dev;
>  	int				ret;
> -	int				port_num;
> +	unsigned int			port_num;
>  
>  	coding.dwDTERate = cpu_to_le32(9600);
>  	coding.bCharFormat = 8;
> -- 
> 1.7.9.5

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2020-05-14 14:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-14  8:05 [PATCH] usb: gadget: u_serial: fix coverity warning: negative index at array Macpaul Lin
2020-05-14  8:05 ` Macpaul Lin
2020-05-14  8:05 ` Macpaul Lin
2020-05-14  9:38 ` Felipe Balbi
2020-05-14  9:38   ` Felipe Balbi
2020-05-14  9:38   ` Felipe Balbi
2020-05-14 14:22 ` Alan Stern
2020-05-14 14:22   ` Alan Stern
2020-05-14 14:22   ` Alan Stern

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.