Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753271AbeAJTZR (ORCPT + 1 other); Wed, 10 Jan 2018 14:25:17 -0500 Received: from mout.web.de ([217.72.192.78]:59984 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753087AbeAJTZM (ORCPT ); Wed, 10 Jan 2018 14:25:12 -0500 Subject: [PATCH 1/7] VMCI: Delete error messages for a failed memory allocation in seven functions 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: <543367a3-e6ca-6afa-63f7-90b5cca23e54@users.sourceforge.net> Date: Wed, 10 Jan 2018 20:24:47 +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:MF4J0NBipaEzUM4EMc20tdTmH4gJkcOsbULwUgMd4Gal93JogKK Lzlogr92y6oIEIs7qDywgjeigQzOXI0h9hi2NZIUpiIIrsQSxyfXqXMfZqINIp4Zxrjaymx SM9nnnPywhyarQAJ62xWkhAcFZNdbyfoAburVLgOmeN9jF6YhK/5lNo3pPqBBf9UbrzoP4V hPxnob+rNxHG0gox3vE/g== X-UI-Out-Filterresults: notjunk:1;V01:K0:JEieEndIybw=:gqM4wnAY//oyjFrwxG3Cb1 3g7VA5MVlDLt5DQm6Nv0OxTX0M/gK6+3MX9Vv/XlMGY5ZVgoWvpWXKuPNsJlB9EtNAk9oJfHQ kCT5ZFbv8YHkdqeGJks0ZYz8Tows9dVx10G8XA2N1MQhhAZDXU6T1+Ep7CoF2k9ApuIp9DnBx tHLOVY+v9leUDn5Rxy/DM8iEFWZaz46RmW744YkwujvOvRXdJy5s80XHj6M6MpWTvGF/2nwvM /kyMrV+SJg2pVNPdZrLI56niNC1+MaD0bjiowMm2Ri4hbtERFvcoJ590XOTTy5aip7cnQ94cz 2ZpljhUwKRAbPu3Bdwh/158QxIjXXGo6wI9DV6W2xU3iTlto7/v97sExuNa8kOZ/BNCt2Zcmu 6xSU7k4kkoScOSDpv06d0bnl8HEGpgb5/7RqZSUZ80jAlzJ0gdGS+yrZHbPtXLUlsLp4mIrNL tnbfj7lamcBd2dCbNelhOXHrZuF6kL2GZkIY00iWs+pa9dfTcdbhHl2+tOc1aP1E/ssTA6wD5 2HzVTZswjEA3wWR86GMOnB+ewNJvx9Aa1qq5Yv3zPvsKlW0nws++MbytBsViQmVPDlrB1BEtp rYIvtz7N3MRVr7tNUqE30aDQXJRhEQwFESno3v+3/1SJTbiB+TgEj91vv0CC5gRM7FVB/fml8 z4/0Oq4pJpPHkqlAsb8jx0zDZzlz2am+/IQkZm5asiryrya6sMEJ5NLM2vkV1/Imcuac4otsr YgS0yDnyrzCLmPuK2Yar1L24uGmzc1rihLfpvBCBVP3SCO8Eptp6rRdWgkHm3soO10u40+NrE FYx3GteATv2+nzdpC2eCuSfvhaRdqFxmtJSWqhZMATui3ag/0w= 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 17:33:39 +0100 Omit extra messages for a memory allocation failure in these functions. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/misc/vmw_vmci/vmci_context.c | 2 -- drivers/misc/vmw_vmci/vmci_datagram.c | 4 +--- drivers/misc/vmw_vmci/vmci_doorbell.c | 4 +--- drivers/misc/vmw_vmci/vmci_guest.c | 14 +++----------- drivers/misc/vmw_vmci/vmci_host.c | 6 +----- 5 files changed, 6 insertions(+), 24 deletions(-) diff --git a/drivers/misc/vmw_vmci/vmci_context.c b/drivers/misc/vmw_vmci/vmci_context.c index 21d0fa592145..c0ea68255340 100644 --- a/drivers/misc/vmw_vmci/vmci_context.c +++ b/drivers/misc/vmw_vmci/vmci_context.c @@ -111,7 +111,6 @@ struct vmci_ctx *vmci_ctx_create(u32 cid, u32 priv_flags, context = kzalloc(sizeof(*context), GFP_KERNEL); if (!context) { - pr_warn("Failed to allocate memory for VMCI context\n"); error = -EINVAL; goto err_out; } @@ -318,7 +317,6 @@ int vmci_ctx_enqueue_datagram(u32 cid, struct vmci_datagram *dg) /* Allocate guest call entry and add it to the target VM's queue. */ dq_entry = kmalloc(sizeof(*dq_entry), GFP_KERNEL); if (dq_entry == NULL) { - pr_warn("Failed to allocate memory for datagram\n"); vmci_ctx_put(context); return VMCI_ERROR_NO_MEM; } diff --git a/drivers/misc/vmw_vmci/vmci_datagram.c b/drivers/misc/vmw_vmci/vmci_datagram.c index 8a4b6bbe1bee..fbe145e2d125 100644 --- a/drivers/misc/vmw_vmci/vmci_datagram.c +++ b/drivers/misc/vmw_vmci/vmci_datagram.c @@ -80,10 +80,8 @@ static int dg_create_handle(u32 resource_id, handle = vmci_make_handle(context_id, resource_id); entry = kmalloc(sizeof(*entry), GFP_KERNEL); - if (!entry) { - pr_warn("Failed allocating memory for datagram entry\n"); + if (!entry) return VMCI_ERROR_NO_MEM; - } entry->run_delayed = (flags & VMCI_FLAG_DG_DELAYED_CB) ? true : false; entry->flags = flags; diff --git a/drivers/misc/vmw_vmci/vmci_doorbell.c b/drivers/misc/vmw_vmci/vmci_doorbell.c index b3fa738ae005..46607ffc94db 100644 --- a/drivers/misc/vmw_vmci/vmci_doorbell.c +++ b/drivers/misc/vmw_vmci/vmci_doorbell.c @@ -423,10 +423,8 @@ int vmci_doorbell_create(struct vmci_handle *handle, return VMCI_ERROR_INVALID_ARGS; entry = kmalloc(sizeof(*entry), GFP_KERNEL); - if (entry == NULL) { - pr_warn("Failed allocating memory for datagram entry\n"); + if (!entry) return VMCI_ERROR_NO_MEM; - } if (vmci_handle_is_invalid(*handle)) { u32 context_id = vmci_get_context_id(); diff --git a/drivers/misc/vmw_vmci/vmci_guest.c b/drivers/misc/vmw_vmci/vmci_guest.c index dad5abee656e..ba18e727c401 100644 --- a/drivers/misc/vmw_vmci/vmci_guest.c +++ b/drivers/misc/vmw_vmci/vmci_guest.c @@ -170,10 +170,8 @@ static int vmci_check_host_caps(struct pci_dev *pdev) struct vmci_datagram *check_msg; check_msg = kmalloc(msg_size, GFP_KERNEL); - if (!check_msg) { - dev_err(&pdev->dev, "%s: Insufficient memory\n", __func__); + if (!check_msg) return -ENOMEM; - } check_msg->dst = vmci_make_handle(VMCI_HYPERVISOR_CONTEXT_ID, VMCI_RESOURCES_QUERY); @@ -457,11 +455,8 @@ static int vmci_guest_probe_device(struct pci_dev *pdev, (unsigned long)iobase, pdev->irq); vmci_dev = devm_kzalloc(&pdev->dev, sizeof(*vmci_dev), GFP_KERNEL); - if (!vmci_dev) { - dev_err(&pdev->dev, - "Can't allocate memory for VMCI device\n"); + if (!vmci_dev) return -ENOMEM; - } vmci_dev->dev = &pdev->dev; vmci_dev->exclusive_vectors = false; @@ -473,11 +468,8 @@ static int vmci_guest_probe_device(struct pci_dev *pdev, vmci_process_bitmap, (unsigned long)vmci_dev); vmci_dev->data_buffer = vmalloc(VMCI_MAX_DG_SIZE); - if (!vmci_dev->data_buffer) { - dev_err(&pdev->dev, - "Can't allocate memory for datagram buffer\n"); + if (!vmci_dev->data_buffer) return -ENOMEM; - } pci_set_master(pdev); /* To enable queue_pair functionality. */ diff --git a/drivers/misc/vmw_vmci/vmci_host.c b/drivers/misc/vmw_vmci/vmci_host.c index 6640e7651533..4246a033de18 100644 --- a/drivers/misc/vmw_vmci/vmci_host.c +++ b/drivers/misc/vmw_vmci/vmci_host.c @@ -755,12 +755,8 @@ static int vmci_host_do_ctx_set_cpt_state(struct vmci_host_dev *vmci_host_dev, return -EFAULT; cpt_buf = kmalloc(set_info.buf_size, GFP_KERNEL); - if (!cpt_buf) { - vmci_ioctl_err( - "cannot allocate memory to set cpt state (type=%d)\n", - set_info.cpt_type); + if (!cpt_buf) return -ENOMEM; - } if (copy_from_user(cpt_buf, (void __user *)(uintptr_t)set_info.cpt_buf, set_info.buf_size)) { -- 2.15.1