Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933957AbdHYPwQ (ORCPT ); Fri, 25 Aug 2017 11:52:16 -0400 Received: from mout.web.de ([212.227.15.3]:57413 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933873AbdHYPwO (ORCPT ); Fri, 25 Aug 2017 11:52:14 -0400 Subject: [PATCH 01/14] vme: Delete 11 error messages for a failed memory allocation From: SF Markus Elfring To: devel@driverdev.osuosl.org, Aaron Sierra , Alessio Igor Bogani , Arnd Bergmann , Augusto Mecking Caringi , Baoyou Xie , Greg Kroah-Hartman , Manohar Vanga , Martyn Welch Cc: LKML , kernel-janitors@vger.kernel.org References: <7ab4be89-4aa6-5537-9839-da090635f249@users.sourceforge.net> Message-ID: Date: Fri, 25 Aug 2017 17:51:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <7ab4be89-4aa6-5537-9839-da090635f249@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:+BCVPftF/SYZ+JVhb7ne44HW1YgpxViAo6cDzkp0ZHxDkdCjG/0 3M76lp+qbJQMvHIYk+/uCyzr6Hlaln93wQaQnwtS5f9d9Yiu1nouIA0z1zRwVdWaoJf1Wgc 4RZ9UM6YzP75LxvNHWGE53OOZdOX5XtnyukjOSFFpOWX2bYCe6QMywazV9F6ZLr9ANXp54S GbpWCjzOcuf24UVLr+8lg== X-UI-Out-Filterresults: notjunk:1;V01:K0:3LaVuvmzF80=:vfVwdHvAo76g5KFRlqRMZC E5xXHH/MrDCw9/tRnKKFHTTEkOT95jXRtTQedE2QmfzNSHd3xa0Q5N77fNfFz3pkv9FHtEENJ CYmAgzJshplNA0Zaebg1W5HMsNLtAYuT2gaBCorNdCGjpu7JLIevJVXAyEFSDAylCzsPoI+kV OvFWIz03r2I44qSzSB03lI+561IqFHNBf0WfVrFrYCChC9auqJ6YVkfHNWR8reuMVEqXcGRxl dvf8t8Bjl3r3FVw1gUy+Yv1oWG+kXkfOBHJNolr1fHtCE0UEJd12Shv7AHDMWWyOJVuUyOQ2H WYutzNhGHcntvCNf09MJuX+aBGaw7cmKe6TZvRGpGS0RCNybafELxOeqAD9fkS1Y0XYbbYC9H 0cM4W7V4c5M7ebAElQey45i51U3HMVuUUJBinPoqbMGu188lC/Nxn3FPwiec9Z/RGXLX6q+1a 8wnlt+Fks0NedRLYJ8KVuSpc3DxbJv3tPH9LFI4OttJOv42dhxpKD8Wwbw44MG7zrRfz4WiCF lH5qMKm6vK6C/Hhb2p6rMC5VEily/Pr273Wub0kSEMIIXVG9st8lLjttrWOIXNrIJcDPtt6Ee Rl//aFgnNwr92hIt2eF2/dve3MiO8W5L50tuno269B6IX1ZQjqkhkwY7KHy3DFpt8nvzE3mra 9yYzUNsk230lNRdp7l32e7RPxqrqLng230oiyPToBw6+++n5lQAtW5OAUYOU6U04EAFa/yA9o Sd8vrj+hqGhhaV/ieaRZDM67aKuVKjZPPgG8koOn2pn/7eMy/npphTaYOMgdNP5FLPlzH/EbE uUNTy8yNGohei+4P/hAejWHfVTwqA2ZSPugv6ltn9pSd0136Vc= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3640 Lines: 118 From: Markus Elfring Date: Thu, 24 Aug 2017 21:38:20 +0200 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/vme/vme.c | 51 ++++++++++++++++----------------------------------- 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c index 6a3ead42aba8..53e87af8e0b8 100644 --- a/drivers/vme/vme.c +++ b/drivers/vme/vme.c @@ -340,7 +340,6 @@ struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address, - if (resource == NULL) { - printk(KERN_WARNING "Unable to allocate resource structure\n"); + if (!resource) goto err_alloc; - } + resource->type = VME_SLAVE; resource->entry = &allocated_image->list; @@ -545,7 +544,6 @@ struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address, - if (resource == NULL) { - printk(KERN_ERR "Unable to allocate resource structure\n"); + if (!resource) goto err_alloc; - } + resource->type = VME_MASTER; resource->entry = &allocated_image->list; @@ -922,7 +920,6 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route) - if (resource == NULL) { - printk(KERN_WARNING "Unable to allocate resource structure\n"); + if (!resource) goto err_alloc; - } + resource->type = VME_DMA; resource->entry = &allocated_ctrlr->list; @@ -965,7 +962,6 @@ struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource) - if (dma_list == NULL) { - printk(KERN_ERR "Unable to allocate memory for new DMA list\n"); + if (!dma_list) return NULL; - } + INIT_LIST_HEAD(&dma_list->entries); dma_list->parent = ctrlr; mutex_init(&dma_list->mtx); @@ -994,13 +990,9 @@ struct vme_dma_attr *vme_dma_pattern_attribute(u32 pattern, u32 type) - if (attributes == NULL) { - printk(KERN_ERR "Unable to allocate memory for attributes structure\n"); + if (!attributes) goto err_attr; - } pattern_attr = kmalloc(sizeof(struct vme_dma_pattern), GFP_KERNEL); - if (pattern_attr == NULL) { - printk(KERN_ERR "Unable to allocate memory for pattern attributes\n"); + if (!pattern_attr) goto err_pat; - } attributes->type = VME_DMA_PATTERN; attributes->private = (void *)pattern_attr; @@ -1038,15 +1030,9 @@ struct vme_dma_attr *vme_dma_pci_attribute(dma_addr_t address) - if (attributes == NULL) { - printk(KERN_ERR "Unable to allocate memory for attributes structure\n"); + if (!attributes) goto err_attr; - } pci_attr = kmalloc(sizeof(struct vme_dma_pci), GFP_KERNEL); - if (pci_attr == NULL) { - printk(KERN_ERR "Unable to allocate memory for PCI attributes\n"); + if (!pci_attr) goto err_pci; - } - - attributes->type = VME_DMA_PCI; attributes->private = (void *)pci_attr; @@ -1086,13 +1072,9 @@ struct vme_dma_attr *vme_dma_vme_attribute(unsigned long long address, - if (attributes == NULL) { - printk(KERN_ERR "Unable to allocate memory for attributes structure\n"); + if (!attributes) goto err_attr; - } vme_attr = kmalloc(sizeof(struct vme_dma_vme), GFP_KERNEL); - if (vme_attr == NULL) { - printk(KERN_ERR "Unable to allocate memory for VME attributes\n"); + if (!vme_attr) goto err_vme; - } attributes->type = VME_DMA_VME; attributes->private = (void *)vme_attr; @@ -1542,7 +1524,6 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev) - if (resource == NULL) { - printk(KERN_ERR "Unable to allocate resource structure\n"); + if (!resource) goto err_alloc; - } + resource->type = VME_LM; resource->entry = &allocated_lm->list; -- 2.14.0