static int mdio_mux_mmioreg_probe(struct platform_device *pdev)
 {
-       struct device_node *np2, *np = pdev->dev.of_node;
+       struct device_node *np = pdev->dev.of_node;
        struct mdio_mux_mmioreg_state *s;
        struct resource res;
        const __be32 *iprop;
         * Verify that the 'reg' property of each child MDIO bus does not
         * set any bits outside of the 'mask'.
         */
-       for_each_available_child_of_node(np, np2) {
+       for_each_available_child_of_node_scoped(np, np2) {
                u64 reg;
 
                if (of_property_read_reg(np2, 0, ®, NULL)) {
                        dev_err(&pdev->dev, "mdio-mux child node %pOF is "
                                "missing a 'reg' property\n", np2);
-                       of_node_put(np2);
                        return -ENODEV;
                }
                if ((u32)reg & ~s->mask) {
                        dev_err(&pdev->dev, "mdio-mux child node %pOF has "
                                "a 'reg' value with unmasked bits\n",
                                np2);
-                       of_node_put(np2);
                        return -ENODEV;
                }
        }