{
        struct gpio_keys_platform_data *pdata;
        struct gpio_keys_button *button;
-       struct fwnode_handle *child;
        int nbuttons, irq;
 
        nbuttons = device_get_child_node_count(dev);
 
        device_property_read_string(dev, "label", &pdata->name);
 
-       device_for_each_child_node(dev, child) {
+       device_for_each_child_node_scoped(dev, child) {
                if (is_of_node(child)) {
                        irq = of_irq_get_byname(to_of_node(child), "irq");
                        if (irq > 0)
                if (fwnode_property_read_u32(child, "linux,code",
                                             &button->code)) {
                        dev_err(dev, "Button without keycode\n");
-                       fwnode_handle_put(child);
                        return ERR_PTR(-EINVAL);
                }