Skip to contentSkip to conversation

UIO: Adjustments for two function implementations

PATCH New SF Markus Elfring 1 participant 4 messages Dec 6, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover UIO: Adjustments for two function implementations

From: Markus Elfring <[email protected]>
Date: Wed, 6 Dec 2017 19:32:10 +0100

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
Delete two error messages for a failed memory allocation
in uio_dmem_genirq_probe()
Return directly after a failed kzalloc() in uio_dmem_genirq_probe() Delete two error messages for a failed memory allocation
in uio_pdrv_genirq_probe()

 drivers/uio/uio_dmem_genirq.c | 11 ++++-------
 drivers/uio/uio_pdrv_genirq.c |  9 +++------
 2 files changed, 7 insertions(+), 13 deletions(-)
Signature · 1 line
2.15.1
#1 lore raw

PATCH 1/3 uio: Delete two error messages for a failed memory allocation in uio_dmem_genirq_probe()

From: Markus Elfring <[email protected]>
Date: Wed, 6 Dec 2017 18:05:12 +0100

Omit extra messages for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/uio/uio_dmem_genirq.c | 2 --
 1 file changed, 2 deletions(-)
drivers/uio/uio_dmem_genirq.c +0 -2
index e1134a4d97f3..b7b0acd1bf01 100644
@@ -160,7 +160,6 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
 		uioinfo = kzalloc(sizeof(*uioinfo), GFP_KERNEL);
 		if (!uioinfo) {
 			ret = -ENOMEM;
-			dev_err(&pdev->dev, "unable to kmalloc\n");
 			goto bad2;
 		}
 		uioinfo->name = pdev->dev.of_node->name;
@@ -188,7 +187,6 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	if (!priv) {
 		ret = -ENOMEM;
-		dev_err(&pdev->dev, "unable to kmalloc\n");
 		goto bad0;
 	}
 
Signature · 1 line
2.15.1
#2 lore raw

PATCH 2/3 uio: Return directly after a failed kzalloc() in uio_dmem_genirq_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 6 Dec 2017 19:11:49 +0100

* Return directly after a call of the function "kzalloc" failed in an if branch.

* Delete the jump label "bad2" which became unnecessary with this refactoring.

---
 drivers/uio/uio_dmem_genirq.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/uio/uio_dmem_genirq.c +4 -5
index b7b0acd1bf01..4f230ce8b861 100644
@@ -158,10 +158,9 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
 
 		/* alloc uioinfo for one device */
 		uioinfo = kzalloc(sizeof(*uioinfo), GFP_KERNEL);
-		if (!uioinfo) {
-			ret = -ENOMEM;
-			goto bad2;
-		}
+		if (!uioinfo)
+			return -ENOMEM;
+
 		uioinfo->name = pdev->dev.of_node->name;
 		uioinfo->version = "devicetree";
 
@@ -285,7 +284,7 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
 	/* kfree uioinfo for OF */
 	if (pdev->dev.of_node)
 		kfree(uioinfo);
- bad2:
+
 	return ret;
 }
 
Signature · 1 line
2.15.1
#3 lore raw

PATCH 3/3 uio: Delete two error messages for a failed memory allocation in uio_pdrv_genirq_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 6 Dec 2017 19:18:12 +0100

Omit extra messages for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/uio/uio_pdrv_genirq.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/uio/uio_pdrv_genirq.c +3 -6
index f598ecddc8a7..327fbe766f1c 100644
@@ -114,10 +114,9 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
 		/* alloc uioinfo for one device */
 		uioinfo = devm_kzalloc(&pdev->dev, sizeof(*uioinfo),
 				       GFP_KERNEL);
-		if (!uioinfo) {
-			dev_err(&pdev->dev, "unable to kmalloc\n");
+		if (!uioinfo)
 			return -ENOMEM;
-		}
+
 		uioinfo->name = pdev->dev.of_node->name;
 		uioinfo->version = "devicetree";
 		/* Multiple IRQs are not supported */
@@ -135,10 +134,8 @@ static int uio_pdrv_genirq_probe(struct platform_device *pdev)
 	}
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv) {
-		dev_err(&pdev->dev, "unable to kmalloc\n");
+	if (!priv)
 		return -ENOMEM;
-	}
 
 	priv->uioinfo = uioinfo;
 	spin_lock_init(&priv->lock);
Signature · 1 line
2.15.1