From: SF Markus Elfring <elfring@users.sourceforge.net>
To: devel@driverdev.osuosl.org, Aaron Sierra <asierra@xes-inc.com>,
Alessio Igor Bogani <alessio.bogani@elettra.eu>,
Arnd Bergmann <arnd@arndb.de>,
Augusto Mecking Caringi <augustocaringi@gmail.com>,
Baoyou Xie <baoyou.xie@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Manohar Vanga <manohar.vanga@gmail.com>,
Martyn Welch <martyn@welchs.me.uk>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 01/14] vme: Delete 11 error messages for a failed memory allocation
Date: Fri, 25 Aug 2017 17:51:52 +0200 [thread overview]
Message-ID: <e2383a24-fbff-ea98-ee64-9177715c0616@users.sourceforge.net> (raw)
In-Reply-To: <7ab4be89-4aa6-5537-9839-da090635f249@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
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
next prev parent reply other threads:[~2017-08-25 15:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-25 15:41 [PATCH 00/14] VME: Adjustments for several function implementations SF Markus Elfring
2017-08-25 15:51 ` SF Markus Elfring [this message]
2017-08-25 15:53 ` [PATCH 02/14] vme: Improve 11 size determinations SF Markus Elfring
2017-08-25 15:57 ` [PATCH 03/14] vme: Move an assignment in vme_new_dma_list() SF Markus Elfring
2017-08-25 15:59 ` [PATCH 04/14] vme: Adjust 48 checks for null pointers SF Markus Elfring
2017-08-25 16:00 ` [PATCH 05/14] vme: Return directly in two functions SF Markus Elfring
2017-08-25 16:02 ` [PATCH 06/14] vme: fake: Delete an error message for a failed memory allocation in fake_init() SF Markus Elfring
2017-08-25 16:03 ` [PATCH 07/14] vme: fake: Improve five size determinations " SF Markus Elfring
2017-08-25 16:05 ` [PATCH 08/14] vme: fake: Adjust 11 checks for null pointers SF Markus Elfring
2017-08-25 16:06 ` [PATCH 09/14] vme: ca91cx42: Delete eight error messages for a failed memory allocation SF Markus Elfring
2017-08-25 16:08 ` [PATCH 10/14] vme: ca91cx42: Improve 12 size determinations SF Markus Elfring
2017-08-25 16:10 ` [PATCH 11/14] vme: ca91cx42: Adjust 14 checks for null pointers SF Markus Elfring
2017-08-25 16:13 ` [PATCH 12/14] vme: tsi148: Delete nine error messages for a failed memory allocation SF Markus Elfring
2017-08-25 16:15 ` [PATCH 13/14] vme: tsi148: Improve 17 size determinations SF Markus Elfring
2017-08-25 20:57 ` Martyn Welch
2017-08-26 7:00 ` SF Markus Elfring
2017-08-30 19:47 ` Martyn Welch
2017-08-30 20:56 ` SF Markus Elfring
2017-08-25 16:17 ` [PATCH 14/14] vme: tsi148: Adjust 14 checks for null pointers SF Markus Elfring
2017-08-25 21:50 ` [PATCH 00/14] VME: Adjustments for several function implementations Martyn Welch
2017-08-26 7:04 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e2383a24-fbff-ea98-ee64-9177715c0616@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=alessio.bogani@elettra.eu \
--cc=arnd@arndb.de \
--cc=asierra@xes-inc.com \
--cc=augustocaringi@gmail.com \
--cc=baoyou.xie@linaro.org \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manohar.vanga@gmail.com \
--cc=martyn@welchs.me.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox