um: vector: Fix an error handling path in 'vector_parse()'
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> Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
parent
be967f7da5
commit
584bfe6354
1 changed files with 3 additions and 3 deletions
|
@ -677,7 +677,7 @@ static struct vector_device *find_device(int n)
|
||||||
static int vector_parse(char *str, int *index_out, char **str_out,
|
static int vector_parse(char *str, int *index_out, char **str_out,
|
||||||
char **error_out)
|
char **error_out)
|
||||||
{
|
{
|
||||||
int n, len, err = -EINVAL;
|
int n, len, err;
|
||||||
char *start = str;
|
char *start = str;
|
||||||
|
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
|
@ -686,7 +686,7 @@ static int vector_parse(char *str, int *index_out, char **str_out,
|
||||||
str++;
|
str++;
|
||||||
if (*str != ':') {
|
if (*str != ':') {
|
||||||
*error_out = "Expected ':' after device number";
|
*error_out = "Expected ':' after device number";
|
||||||
return err;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
*str = '\0';
|
*str = '\0';
|
||||||
|
|
||||||
|
@ -699,7 +699,7 @@ static int vector_parse(char *str, int *index_out, char **str_out,
|
||||||
str++;
|
str++;
|
||||||
if (find_device(n)) {
|
if (find_device(n)) {
|
||||||
*error_out = "Device already configured";
|
*error_out = "Device already configured";
|
||||||
return err;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*index_out = n;
|
*index_out = n;
|
||||||
|
|
Loading…
Add table
Reference in a new issue