Re: [PATCH 1/9] um/drivers/vector_user: Delete unnecessary code in user_init_raw_fds()

2018-03-11 Thread Anton Ivanov

Thanks, well noted.

It still does not fix it completely though.

Re-reading the code it will leak a fd if the malloc for result fails. 
That return result; there should be inside the conditional falling back 
to cleanup if the alloc fails.


A.


On 03/11/18 15:16, SF Markus Elfring wrote:

From: Markus Elfring 
Date: Sun, 11 Mar 2018 11:36:18 +0100

* One condition check could never be reached with a non-null pointer
   at the end of this function. Thus remove the corresponding statement.

* Delete an initialisation for the local variable "result"
   which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring 
---
  arch/um/drivers/vector_user.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/um/drivers/vector_user.c b/arch/um/drivers/vector_user.c
index 4291f1a5d342..d6a6207d4061 100644
--- a/arch/um/drivers/vector_user.c
+++ b/arch/um/drivers/vector_user.c
@@ -211,7 +211,7 @@ static struct vector_fds *user_init_raw_fds(struct arglist 
*ifspec)
struct sockaddr_ll sock;
int err = -ENOMEM;
char *iface;
-   struct vector_fds *result = NULL;
+   struct vector_fds *result;
int optval = 1;
  
  
@@ -276,8 +276,6 @@ static struct vector_fds *user_init_raw_fds(struct arglist *ifspec)

os_close_file(rxfd);
if (txfd >= 0)
os_close_file(txfd);
-   if (result != NULL)
-   kfree(result);
return NULL;
  }
  


--
Anton R. Ivanov

Cambridge Greys Limited, England and Wales company No 10273661
http://www.cambridgegreys.com/



Re: [PATCH 1/9] um/drivers/vector_user: Delete unnecessary code in user_init_raw_fds()

2018-03-11 Thread Anton Ivanov

Thanks, well noted.

It still does not fix it completely though.

Re-reading the code it will leak a fd if the malloc for result fails. 
That return result; there should be inside the conditional falling back 
to cleanup if the alloc fails.


A.


On 03/11/18 15:16, SF Markus Elfring wrote:

From: Markus Elfring 
Date: Sun, 11 Mar 2018 11:36:18 +0100

* One condition check could never be reached with a non-null pointer
   at the end of this function. Thus remove the corresponding statement.

* Delete an initialisation for the local variable "result"
   which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring 
---
  arch/um/drivers/vector_user.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/um/drivers/vector_user.c b/arch/um/drivers/vector_user.c
index 4291f1a5d342..d6a6207d4061 100644
--- a/arch/um/drivers/vector_user.c
+++ b/arch/um/drivers/vector_user.c
@@ -211,7 +211,7 @@ static struct vector_fds *user_init_raw_fds(struct arglist 
*ifspec)
struct sockaddr_ll sock;
int err = -ENOMEM;
char *iface;
-   struct vector_fds *result = NULL;
+   struct vector_fds *result;
int optval = 1;
  
  
@@ -276,8 +276,6 @@ static struct vector_fds *user_init_raw_fds(struct arglist *ifspec)

os_close_file(rxfd);
if (txfd >= 0)
os_close_file(txfd);
-   if (result != NULL)
-   kfree(result);
return NULL;
  }
  


--
Anton R. Ivanov

Cambridge Greys Limited, England and Wales company No 10273661
http://www.cambridgegreys.com/