Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8fe01296 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'net_of_node_put'

Julia Lawall says:

====================
add missing of_node_put

The various for_each device_node iterators performs an of_node_get on each
iteration, so a break out of the loop requires an of_node_put.

The complete semantic patch that fixes this problem is
(http://coccinelle.lip6.fr

):

// <smpl>
@r@
local idexpression n;
expression e1,e2;
iterator name for_each_node_by_name, for_each_node_by_type,
for_each_compatible_node, for_each_matching_node,
for_each_matching_node_and_match, for_each_child_of_node,
for_each_available_child_of_node, for_each_node_with_property;
iterator i;
statement S;
expression list [n1] es;
@@

(
(
for_each_node_by_name(n,e1) S
|
for_each_node_by_type(n,e1) S
|
for_each_compatible_node(n,e1,e2) S
|
for_each_matching_node(n,e1) S
|
for_each_matching_node_and_match(n,e1,e2) S
|
for_each_child_of_node(e1,n) S
|
for_each_available_child_of_node(e1,n) S
|
for_each_node_with_property(n,e1) S
)
&
i(es,n,...) S
)

@@
local idexpression r.n;
iterator r.i;
expression e;
expression list [r.n1] es;
@@

 i(es,n,...) {
   ...
(
   of_node_put(n);
|
   e = n
|
   return n;
|
+  of_node_put(n);
?  return ...;
)
   ...
 }

@@
local idexpression r.n;
iterator r.i;
expression e;
expression list [r.n1] es;
@@

 i(es,n,...) {
   ...
(
   of_node_put(n);
|
   e = n
|
+  of_node_put(n);
?  break;
)
   ...
 }
... when != n

@@
local idexpression r.n;
iterator r.i;
expression e;
identifier l;
expression list [r.n1] es;
@@

 i(es,n,...) {
   ...
(
   of_node_put(n);
|
   e = n
|
+  of_node_put(n);
?  goto l;
)
   ...
 }
...
l: ... when != n// </smpl>
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 7e3b6e74 26b7974d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -977,9 +977,11 @@ static int bgx_init_of_phy(struct bgx *bgx)
		SET_NETDEV_DEV(&bgx->lmac[lmac].netdev, &bgx->pdev->dev);
		bgx->lmac[lmac].lmacid = lmac;
		lmac++;
		if (lmac == MAX_LMAC_PER_BGX)
		if (lmac == MAX_LMAC_PER_BGX) {
			of_node_put(np_child);
			break;
		}
	}
	return 0;
}

+3 −1
Original line number Diff line number Diff line
@@ -2817,9 +2817,11 @@ static int mv643xx_eth_shared_of_probe(struct platform_device *pdev)

	for_each_available_child_of_node(np, pnp) {
		ret = mv643xx_eth_shared_of_add_port(pdev, pnp);
		if (ret)
		if (ret) {
			of_node_put(pnp);
			return ret;
		}
	}
	return 0;
}

+6 −2
Original line number Diff line number Diff line
@@ -2637,9 +2637,11 @@ static void init_secondary_ports(struct gbe_priv *gbe_dev,
			mac_phy_link = true;

		slave->open = true;
		if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves)
		if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves) {
			of_node_put(port);
			break;
		}
	}

	/* of_phy_connect() is needed only for MAC-PHY interface */
	if (!mac_phy_link)
@@ -3137,9 +3139,11 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev,
			continue;
		}
		gbe_dev->num_slaves++;
		if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves)
		if (gbe_dev->num_slaves >= gbe_dev->max_num_slaves) {
			of_node_put(interface);
			break;
		}
	}
	of_node_put(interfaces);

	if (!gbe_dev->num_slaves)
+2 −0
Original line number Diff line number Diff line
@@ -113,12 +113,14 @@ static int mdio_mux_mmioreg_probe(struct platform_device *pdev)
		if (!iprop || len != sizeof(uint32_t)) {
			dev_err(&pdev->dev, "mdio-mux child node %s is "
				"missing a 'reg' property\n", np2->full_name);
			of_node_put(np2);
			return -ENODEV;
		}
		if (be32_to_cpup(iprop) & ~s->mask) {
			dev_err(&pdev->dev, "mdio-mux child node %s has "
				"a 'reg' value with unmasked bits\n",
				np2->full_name);
			of_node_put(np2);
			return -ENODEV;
		}
	}
+1 −0
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ int mdio_mux_init(struct device *dev,
			dev_err(dev,
				"Error: Failed to allocate memory for child\n");
			ret_val = -ENOMEM;
			of_node_put(child_bus_node);
			break;
		}
		cb->bus_number = v;
Loading