Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754354AbeAJTbB (ORCPT + 1 other); Wed, 10 Jan 2018 14:31:01 -0500 Received: from mout.web.de ([212.227.17.11]:52095 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753979AbeAJTa7 (ORCPT ); Wed, 10 Jan 2018 14:30:59 -0500 Subject: [PATCH 6/7] VMCI: Less function calls in qp_broker_create() after error detection From: SF Markus Elfring To: kernel-janitors@vger.kernel.org, Al Viro , Alexey Dobriyan , Andrew Morton , Arnd Bergmann , Dan Carpenter , Greg Kroah-Hartman , "Gustavo A. R. Silva" , Ingo Molnar , Masahiro Yamada Cc: LKML References: <2747f123-a95d-bc68-b858-0327dce3758b@users.sourceforge.net> Message-ID: Date: Wed, 10 Jan 2018 20:30:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <2747f123-a95d-bc68-b858-0327dce3758b@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:pDacuzchBgvENgpoakoVlAYg36HhSrUjnE87lqNVjcB7C3wMdXp lCWpZ2vJzwq9SCaBpT7RC4Fq2fHj+H8XDcVZ8CEJNN9v47N0IsKux+Cr3s6EHwu5xY8yYIB pEGsrelyZH5oNZX7ghmiHvZp9mfHPHp8yXUKTedO5d20RicjWp1Yh/ORGA1bKUa+EZcAvLu F2Mk2hqu+8lPXh1j0a/Rw== X-UI-Out-Filterresults: notjunk:1;V01:K0:npU8Z6HbJaA=:kSzIFEtVaRrx6htI7JBpSI 7/zhs7Vl6F+ZSRjCUCyQCLBgvc3NKIKk8foj2pFWhusSrepKaNZNfHTbQ7V/s6AnI7YtJfMvC qxYU6rIhPpcCPfrf2myVmNTf/la01tyyaNxMzuiXgtZo+McnhrZLQvQucVSxxeo1NEwf594Ec dK5x3R3edE70sLZFpiCJcOl3fpxnG7OiqPZmTqEQrAH1zIH2f3RFmjqFPvh4TJOZMHJSQ/4iY np/or64+WtTN1ZGJRaSN+KS8Kx5pOP2KFA/jgMg7xpEEuuTXbOJ4V29JTJwmHz0nUiSc7IGyV um6pNsYq50u4S+uC2+egMdxhxEXYoBXLXN1QsCzOKoQExrYYNQtOoMMdO0ihiyO+suav1j5Jw vvjlLN018ZeccAwrLsbQLRaOoVCD69nGU/M2PixsrMOZFk3WjvfIL9u3ZvdwnXXtM4l5s4S1O tKNLhxLzo5iJkvFzsV14QYj1dwxfNb31so7mqcAxqftNUW7i3rado4ybdhmZ2lRj2Z8sia70v FEfEhAtLYaxpJhGDoWMVZhRty3xglFPQX3d+WUptNTMRCZgx6xW1KgSCTojLhHAHueceNE9+H ckzZiaqF1qZHif1zhYXQvC1eThcc7ekyiEWu0GcknoDoMTp2QQohzogueeNRZ0T8z4mL8kjZV eKWpf/LLqcrWQ13gZXVUmw/+lwu4yu9BEKgPd5nSMMF+Kdb5qBBPmaGBCz2c4WfOWPdLY2ANE OFjRvpjtZpBrXa11tLWnpXJvtX9rLPHhu7uITmUbKFWbhvDOv3XBpNkAskqNT6OkQ05mY5XbD EsoAHdrzRsPAqHI7KTzVboU4wZtyG96PgCxg7s7W/DIIbVG514= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Markus Elfring Date: Wed, 10 Jan 2018 19:39:45 +0100 The function "qp_host_free_queue" was called in two cases by the function "qp_broker_create" during error handling even if the passed data structure member contained a null pointer. Adjust jump targets according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/misc/vmw_vmci/vmci_queue_pair.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c index 5546274dec5d..9b7dcad38f3d 100644 --- a/drivers/misc/vmw_vmci/vmci_queue_pair.c +++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c @@ -1358,12 +1358,12 @@ static int qp_broker_create(struct vmci_handle handle, entry->produce_q = qp_host_alloc_queue(guest_produce_size); if (entry->produce_q == NULL) { result = VMCI_ERROR_NO_MEM; - goto error; + goto free_entry; } entry->consume_q = qp_host_alloc_queue(guest_consume_size); if (entry->consume_q == NULL) { result = VMCI_ERROR_NO_MEM; - goto error; + goto free_produce_queue; } qp_init_queue_mutex(entry->produce_q, entry->consume_q); @@ -1377,7 +1377,7 @@ static int qp_broker_create(struct vmci_handle handle, PAGE_SIZE, GFP_KERNEL); if (entry->local_mem == NULL) { result = VMCI_ERROR_NO_MEM; - goto error; + goto free_consume_queue; } entry->state = VMCIQPB_CREATED_MEM; entry->produce_q->q_header = entry->local_mem; @@ -1393,7 +1393,7 @@ static int qp_broker_create(struct vmci_handle handle, entry->produce_q, entry->consume_q); if (result < VMCI_SUCCESS) - goto error; + goto free_consume_queue; entry->state = VMCIQPB_CREATED_MEM; } else { @@ -1418,7 +1418,7 @@ static int qp_broker_create(struct vmci_handle handle, if (result != VMCI_SUCCESS) { pr_warn("Failed to add new resource (handle=0x%x:0x%x), error: %d", handle.context, handle.resource, result); - goto error; + goto free_consume_queue; } entry->qp.handle = vmci_resource_handle(&entry->resource); @@ -1433,9 +1433,11 @@ static int qp_broker_create(struct vmci_handle handle, return VMCI_SUCCESS; - error: - qp_host_free_queue(entry->produce_q, guest_produce_size); +free_consume_queue: qp_host_free_queue(entry->consume_q, guest_consume_size); +free_produce_queue: + qp_host_free_queue(entry->produce_q, guest_produce_size); +free_entry: kfree(entry); return result; } -- 2.15.1