lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 9 Nov 2019 10:00:27 +0100
From:   Markus Elfring <Markus.Elfring@....de>
To:     netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>,
        Madalin Bucur <madalin.bucur@....com>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org, Wen Yang <wen.yang99@....com.cn>
Subject: [PATCH 1/3] fsl/fman: Add missing put_device() calls in mac_probe()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Sat, 9 Nov 2019 08:14:35 +0100

A coccicheck run provided information like the following.

drivers/net/ethernet/freescale/fman/mac.c:874:1-7: ERROR: missing put_device;
call of_find_device_by_node on line 659, but without a corresponding
object release within this function.
drivers/net/ethernet/freescale/fman/mac.c:874:1-7: ERROR: missing put_device;
call of_find_device_by_node on line 760, but without a corresponding
object release within this function.

Generated by: scripts/coccinelle/free/put_device.cocci

Thus adjust jump targets to fix the exception handling for this
function implementation.

Fixes: 3933961682a30ae7d405cda344c040a129fea422 ("fsl/fman: Add FMan MAC driver")
Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/net/ethernet/freescale/fman/mac.c | 28 ++++++++++++++---------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
index f0806ace1ae2..e0680257532c 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -668,7 +668,7 @@ static int mac_probe(struct platform_device *_of_dev)
 	if (err) {
 		dev_err(dev, "failed to read cell-index for %pOF\n", dev_node);
 		err = -EINVAL;
-		goto _return_of_node_put;
+		goto _put_device;
 	}
 	/* cell-index 0 => FMan id 1 */
 	fman_id = (u8)(val + 1);
@@ -677,7 +677,7 @@ static int mac_probe(struct platform_device *_of_dev)
 	if (!priv->fman) {
 		dev_err(dev, "fman_bind(%pOF) failed\n", dev_node);
 		err = -ENODEV;
-		goto _return_of_node_put;
+		goto _put_device;
 	}

 	of_node_put(dev_node);
@@ -687,7 +687,7 @@ static int mac_probe(struct platform_device *_of_dev)
 	if (err < 0) {
 		dev_err(dev, "of_address_to_resource(%pOF) = %d\n",
 			mac_node, err);
-		goto _return_of_get_parent;
+		goto _put_parent_device;
 	}

 	mac_dev->res = __devm_request_region(dev,
@@ -697,7 +697,7 @@ static int mac_probe(struct platform_device *_of_dev)
 	if (!mac_dev->res) {
 		dev_err(dev, "__devm_request_mem_region(mac) failed\n");
 		err = -EBUSY;
-		goto _return_of_get_parent;
+		goto _put_parent_device;
 	}

 	priv->vaddr = devm_ioremap(dev, mac_dev->res->start,
@@ -705,12 +705,12 @@ static int mac_probe(struct platform_device *_of_dev)
 	if (!priv->vaddr) {
 		dev_err(dev, "devm_ioremap() failed\n");
 		err = -EIO;
-		goto _return_of_get_parent;
+		goto _put_parent_device;
 	}

 	if (!of_device_is_available(mac_node)) {
 		err = -ENODEV;
-		goto _return_of_get_parent;
+		goto _put_parent_device;
 	}

 	/* Get the cell-index */
@@ -718,7 +718,7 @@ static int mac_probe(struct platform_device *_of_dev)
 	if (err) {
 		dev_err(dev, "failed to read cell-index for %pOF\n", mac_node);
 		err = -EINVAL;
-		goto _return_of_get_parent;
+		goto _put_parent_device;
 	}
 	priv->cell_index = (u8)val;

@@ -727,7 +727,7 @@ static int mac_probe(struct platform_device *_of_dev)
 	if (IS_ERR(mac_addr)) {
 		dev_err(dev, "of_get_mac_address(%pOF) failed\n", mac_node);
 		err = -EINVAL;
-		goto _return_of_get_parent;
+		goto _put_parent_device;
 	}
 	ether_addr_copy(mac_dev->addr, mac_addr);

@@ -737,14 +737,14 @@ static int mac_probe(struct platform_device *_of_dev)
 		dev_err(dev, "of_count_phandle_with_args(%pOF, fsl,fman-ports) failed\n",
 			mac_node);
 		err = nph;
-		goto _return_of_get_parent;
+		goto _put_parent_device;
 	}

 	if (nph != ARRAY_SIZE(mac_dev->port)) {
 		dev_err(dev, "Not supported number of fman-ports handles of mac node %pOF from device tree\n",
 			mac_node);
 		err = -EINVAL;
-		goto _return_of_get_parent;
+		goto _put_parent_device;
 	}

 	for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) {
@@ -770,7 +770,7 @@ static int mac_probe(struct platform_device *_of_dev)
 			dev_err(dev, "dev_get_drvdata(%pOF) failed\n",
 				dev_node);
 			err = -EINVAL;
-			goto _return_of_node_put;
+			goto _put_device;
 		}
 		of_node_put(dev_node);
 	}
@@ -866,6 +866,12 @@ static int mac_probe(struct platform_device *_of_dev)

 	goto _return;

+_put_parent_device:
+	put_device(&of_dev->dev);
+	goto _return_of_get_parent;
+
+_put_device:
+	put_device(&of_dev->dev);
 _return_of_node_put:
 	of_node_put(dev_node);
 _return_of_get_parent:
--
2.24.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ