Received: by 10.192.245.15 with SMTP id i15csp1207990imn; Sun, 11 Mar 2018 08:23:21 -0700 (PDT) X-Google-Smtp-Source: AG47ELunT/8nm61TstavJ44QD5vMYUsYqJmDNMtXaVFOLOwotY3WOo9rGXCAPdEcJbfEW/l+35yG X-Received: by 2002:a17:902:8349:: with SMTP id z9-v6mr5149213pln.163.1520781801485; Sun, 11 Mar 2018 08:23:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520781801; cv=none; d=google.com; s=arc-20160816; b=WVRHRIuIZgQoymMXwi58V73C1o0eJutzBS5Q9V6bjhTvq2fgef1BiSyqdjontwQ/HM y8O4iKPdcQxrTmzSP0IC3u2L31oAETuAvzraIWwl+hFZu0+hNBfy5e2/sSeDl+ubOaW5 WzUd3+xv1g5dl9Va1TeIjfRwmKm8Z9oe2cyeQtANy6gRDyEINWZeQ3shclmpOnEUS2QT FbA+mgn7lV61Xu8n6WPe6wUJpZGMEyuvPszvyBYqFVVU1qqY3Nxz59pc6gXiQsq6HBMn XvdSoXC7R/ibrZe/dcF3FKgAY+6QbTDoIxh3PfoHvETv3YV/U7qXyzE1KMVnbVXb8dDw rFvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:arc-authentication-results; bh=9NC5XgLpfLBCWOBsEnltuEeV9QchzJ4DTyO7+1esmcM=; b=zQ6IWf6Y3ZJW4wuVGWmEbDvPa8Dbh3uPwDsoS1FmV2mKCA4Um/hxekMaUOhU1QGiW7 R+3Hpaihvi1gw4/EHPar4xdEW3+vXLvIhdaUuwJb8RlSIK5UnzzWAkVRPX1BDETM6h0J Oib315ufJo84S5My55EfQCkxVfqd4etfS9faalC3MPlLQ7sxaDWu+BPbCvASObry7aRN 2xRiMVqWHQUpIe6MP1Ntv6IvVVh8WHyvNLOt5GHVof9Spqg9ZQSpjv7XnPd1IzCqPzBN qan82o6oiM6KZqiTJHPkhCo3rAYAwcbSoDN+ip+Vwx10BoLcoQTTds81BONMqTG5Du3E 9fbQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d90-v6si4461986pld.40.2018.03.11.08.23.07; Sun, 11 Mar 2018 08:23:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932216AbeCKPV7 (ORCPT + 99 others); Sun, 11 Mar 2018 11:21:59 -0400 Received: from mout.web.de ([212.227.17.12]:59059 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932137AbeCKPV5 (ORCPT ); Sun, 11 Mar 2018 11:21:57 -0400 Received: from [192.168.1.2] ([77.182.27.43]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LtFYd-1eXDSE2x4N-012mSI; Sun, 11 Mar 2018 16:21:45 +0100 Subject: [PATCH 6/9] um/drivers/vector_user: Less checks in user_init_socket_fds() after error detection From: SF Markus Elfring To: user-mode-linux-devel@lists.sourceforge.net, Anton Ivanov , Jeff Dike , Richard Weinberger Cc: user-mode-linux-user@lists.sourceforge.net, kernel-janitors@vger.kernel.org, LKML References: Message-ID: Date: Sun, 11 Mar 2018 16:21:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:wsEplIWHHY5y0bkNJW2UvdSmz9q79Nel8epTAuEeGRNwKEpaD1L o1v05eGdPjAK658332JwtDYN6t4/xM6DwRphgBotoEVMjtD4ITe+tPcVGA/HSOfpo8xIclh avFwHgQ5iYwYh6B4Yw/igLjU4W3tUSpzRz3iKDOMDRRbRMxqXw2eoiDFjtRrbqPZaSaex3r JxMXlfQhvZnDwCpuC2+cQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:yUvKFoXjULk=:9MPMRAPwI7A+DWZC/+SaR2 MsBBsgW0kLb1QQva82k3LezWQp61tfpPj+CQQ12TI2gOFDwB+NJiGBRlHq71kjPxsVVyoqqHN rAo4f9ikVP9Vzmb95O3+VtGT+7L8u1zZiG1F4K6dmf33cU/bGN7u7I3/nQFKNDEXcHpfEkDSl iacgs34mV0dFeNEeLuIrb93U7vCTKkSdKSUjyA5TBlq/cpbL6Ti5ATvF7k4BjTkYhlqQJ75lA INyW7snmD/loTwABJEuOiNbAH2fXjXe1qkH6AD/nfd+ON8WVxiKWeS0IZspYFuh0SwvZYhPGU AHbCxMpMeZLMJInrgQNpA1JnRz4QiXrn1ZoFJTENWmXpESjW8GjndXkbRZcfuEm2jJH8p67tt S3kIp16TQPOWwKAcfiPfBX4Pmgg2Pn/AHspmuIJFO5GCQLj4oW68oF78bXr0Ex8Ee3cAVOHnl BBo8taR5kvpTTo9Ger4vOmZX6x9wCEfZETMAdtcZJfEbUv4As3288Tn5Mw3O2lipq3GcdDbtl APL+zdUKZtlQVX3J1od4vsoCNEpl/470SO+jS25z1yaCOANfWcPwYn+U3Jm6P9+Gs5doexUbM PnlWbC8xrIFVYJBBmlPMQGe5y4twohGmV2GXgTlJmHIj3PxwAG4JWSsyP75IF23PiNYhr6+26 Ae8RWHABJ3MJ5mW6Ou0ZV5DlN6hrU1PZJ757wxntw2VDEtHufcoOO437vJd9szccECN/9SfcS D18nt+ONK/zOqRkrvsiLBZhV9NEGiV4itgNnLPfxYrZvJoVkqRVuq6bhCi5+MeSklPAQODOhz VSotyy1XmCvEYHlJZHp94CL+VzoUDkqzSOTxbPC1LjMhT3TH50= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring 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 --- 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