From: Markus Elfring <elfr...@users.sourceforge.net>
Date: Sun, 11 Mar 2018 14:56:38 +0100

Two checks could be repeated by the user_init_socket_fds() function
during error handling even if the relevant properties can be determined
for the involved variables before by source code analysis.

* Adjust jump targets.

* Delete two sanity checks and a call of the function "kfree"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfr...@users.sourceforge.net>
---
 arch/um/drivers/vector_user.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/arch/um/drivers/vector_user.c b/arch/um/drivers/vector_user.c
index 2dee1e183387..4c265262a369 100644
--- a/arch/um/drivers/vector_user.c
+++ b/arch/um/drivers/vector_user.c
@@ -375,13 +375,13 @@ static struct vector_fds *user_init_socket_fds(struct 
arglist *ifspec, int id)
                        "socket_open : could not open socket, error = %d",
                        -errno
                );
-               goto cleanup;
+               goto free_info;
        }
        if (bind(fd,
                (struct sockaddr *) gairesult->ai_addr,
                gairesult->ai_addrlen)) {
                printk(UM_KERN_ERR L2TPV3_BIND_FAIL, errno);
-               goto cleanup;
+               goto close_file;
        }
 
        freeaddrinfo(gairesult);
@@ -403,7 +403,8 @@ static struct vector_fds *user_init_socket_fds(struct 
arglist *ifspec, int id)
                result->remote_addr = uml_kmalloc(
                        gairesult->ai_addrlen, UM_GFP_KERNEL);
                if (result->remote_addr == NULL)
-                       goto cleanup;
+                       goto free_result;
+
                result->remote_addr_size = gairesult->ai_addrlen;
                memcpy(
                        result->remote_addr,
@@ -413,16 +414,13 @@ static struct vector_fds *user_init_socket_fds(struct 
arglist *ifspec, int id)
        }
        freeaddrinfo(gairesult);
        return result;
-cleanup:
-       freeaddrinfo(gairesult);
-
-       if (fd >= 0)
-               os_close_file(fd);
-       if (result != NULL) {
-               kfree(result->remote_addr);
-               kfree(result);
-       }
 
+free_result:
+       kfree(result);
+close_file:
+       os_close_file(fd);
+free_info:
+       freeaddrinfo(gairesult);
        printk(UM_KERN_ERR "%s: init failed: %d", __func__, -ENOMEM);
        return NULL;
 }
-- 
2.16.2

Reply via email to