UIO: Adjustments for two function implementations
Subsystems (2)
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
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
@@ -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
PATCH 2/3 uio: Return directly after a failed kzalloc() in uio_dmem_genirq_probe()
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 3/3 uio: Delete two error messages for a failed memory allocation in uio_pdrv_genirq_probe()
In reply to SF Markus ElfringFrom: 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
@@ -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