All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] um: vector: Fix an error handling path in 'vector_parse()'
@ 2018-01-27 10:55 ` Christophe JAILLET
  0 siblings, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2018-01-27 10:55 UTC (permalink / raw)
  To: kernel-janitors

If 'find_device()' finds something, we set '*error_out' and we should
return an error. However, 'err' is known to be 0 at this point.

Explicitly return -EINVAL instead.

While at it, remove the initialization of 'err' at the beginning of the
function and also explicitly return an error code if the first check
fails.

Fixes: ad1f62ab2bd4 ("High Performance UML Vector Network Driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Not sure if correct, but it looks spurious to set 'error_out' and return
0 (i.e. success)
---
 arch/um/drivers/vector_kern.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index 3c1e6ad91016..6fab02a126e6 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -677,7 +677,7 @@ static struct vector_device *find_device(int n)
 static int vector_parse(char *str, int *index_out, char **str_out,
 			char **error_out)
 {
-	int n, len, err = -EINVAL;
+	int n, len, err;
 	char *start = str;
 
 	len = strlen(str);
@@ -686,7 +686,7 @@ static int vector_parse(char *str, int *index_out, char **str_out,
 		str++;
 	if (*str != ':') {
 		*error_out = "Expected ':' after device number";
-		return err;
+		return -EINVAL;
 	}
 	*str = '\0';
 
@@ -699,7 +699,7 @@ static int vector_parse(char *str, int *index_out, char **str_out,
 	str++;
 	if (find_device(n)) {
 		*error_out = "Device already configured";
-		return err;
+		return -EINVAL;
 	}
 
 	*index_out = n;
-- 
2.14.1


---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus


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

* [uml-devel] [PATCH 2/2] um: vector: Fix an error handling path in 'vector_parse()'
@ 2018-01-27 10:55 ` Christophe JAILLET
  0 siblings, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2018-01-27 10:55 UTC (permalink / raw)
  To: jdike, richard, anton.ivanov, user-mode-linux-user
  Cc: Christophe JAILLET, kernel-janitors, user-mode-linux-devel

If 'find_device()' finds something, we set '*error_out' and we should
return an error. However, 'err' is known to be 0 at this point.

Explicitly return -EINVAL instead.

While at it, remove the initialization of 'err' at the beginning of the
function and also explicitly return an error code if the first check
fails.

Fixes: ad1f62ab2bd4 ("High Performance UML Vector Network Driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Not sure if correct, but it looks spurious to set 'error_out' and return
0 (i.e. success)
---
 arch/um/drivers/vector_kern.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index 3c1e6ad91016..6fab02a126e6 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -677,7 +677,7 @@ static struct vector_device *find_device(int n)
 static int vector_parse(char *str, int *index_out, char **str_out,
 			char **error_out)
 {
-	int n, len, err = -EINVAL;
+	int n, len, err;
 	char *start = str;
 
 	len = strlen(str);
@@ -686,7 +686,7 @@ static int vector_parse(char *str, int *index_out, char **str_out,
 		str++;
 	if (*str != ':') {
 		*error_out = "Expected ':' after device number";
-		return err;
+		return -EINVAL;
 	}
 	*str = '\0';
 
@@ -699,7 +699,7 @@ static int vector_parse(char *str, int *index_out, char **str_out,
 	str++;
 	if (find_device(n)) {
 		*error_out = "Device already configured";
-		return err;
+		return -EINVAL;
 	}
 
 	*index_out = n;
-- 
2.14.1


---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

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

* Re: [uml-devel] [PATCH 2/2] um: vector: Fix an error handling path in 'vector_parse()'
  2018-01-27 10:55 ` [uml-devel] " Christophe JAILLET
  (?)
@ 2018-01-27 11:42 ` Anton Ivanov
  2018-02-07  0:01   ` Richard Weinberger
  -1 siblings, 1 reply; 4+ messages in thread
From: Anton Ivanov @ 2018-01-27 11:42 UTC (permalink / raw)
  To: user-mode-linux-devel; +Cc: Richard Weinberger

Thanks, looks correct, +1

Richard, can you add it to the next pull.

Thanks in advance,

A.



On 27/01/18 10:55, Christophe JAILLET wrote:
> If 'find_device()' finds something, we set '*error_out' and we should
> return an error. However, 'err' is known to be 0 at this point.
>
> Explicitly return -EINVAL instead.
>
> While at it, remove the initialization of 'err' at the beginning of the
> function and also explicitly return an error code if the first check
> fails.
>
> Fixes: ad1f62ab2bd4 ("High Performance UML Vector Network Driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Not sure if correct, but it looks spurious to set 'error_out' and return
> 0 (i.e. success)
> ---
>  arch/um/drivers/vector_kern.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> index 3c1e6ad91016..6fab02a126e6 100644
> --- a/arch/um/drivers/vector_kern.c
> +++ b/arch/um/drivers/vector_kern.c
> @@ -677,7 +677,7 @@ static struct vector_device *find_device(int n)
>  static int vector_parse(char *str, int *index_out, char **str_out,
>  			char **error_out)
>  {
> -	int n, len, err = -EINVAL;
> +	int n, len, err;
>  	char *start = str;
>  
>  	len = strlen(str);
> @@ -686,7 +686,7 @@ static int vector_parse(char *str, int *index_out, char **str_out,
>  		str++;
>  	if (*str != ':') {
>  		*error_out = "Expected ':' after device number";
> -		return err;
> +		return -EINVAL;
>  	}
>  	*str = '\0';
>  
> @@ -699,7 +699,7 @@ static int vector_parse(char *str, int *index_out, char **str_out,
>  	str++;
>  	if (find_device(n)) {
>  		*error_out = "Device already configured";
> -		return err;
> +		return -EINVAL;
>  	}
>  
>  	*index_out = n;



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


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

* Re: [uml-devel] [PATCH 2/2] um: vector: Fix an error handling path in 'vector_parse()'
  2018-01-27 11:42 ` Anton Ivanov
@ 2018-02-07  0:01   ` Richard Weinberger
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Weinberger @ 2018-02-07  0:01 UTC (permalink / raw)
  To: Anton Ivanov; +Cc: christophe.jaillet, user-mode-linux-devel

Anton,

Am Samstag, 27. Januar 2018, 12:42:17 CET schrieb Anton Ivanov:
> Thanks, looks correct, +1
> 
> Richard, can you add it to the next pull.
> 
> Thanks in advance,

Is that a Reviewed-by? :)
(Same for the other patch)

Thanks,
//richard

P.s: Something is odd with your mail setup, none of your mails made it to the 
mailinglist.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


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

end of thread, other threads:[~2018-02-07  0:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-27 10:55 [PATCH 2/2] um: vector: Fix an error handling path in 'vector_parse()' Christophe JAILLET
2018-01-27 10:55 ` [uml-devel] " Christophe JAILLET
2018-01-27 11:42 ` Anton Ivanov
2018-02-07  0:01   ` Richard Weinberger

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.