// Copyright (C) 2022 Laurent Pinchart <laurent.pinchart@idesonboard.com>
 // Copyright (C) 2018 Avnet, Inc.
 
+#include <linux/cleanup.h>
 #include <linux/err.h>
 #include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 static int max20086_parse_regulators_dt(struct max20086 *chip, bool *boot_on)
 {
        struct of_regulator_match *matches;
-       struct device_node *node;
        unsigned int i;
        int ret;
 
-       node = of_get_child_by_name(chip->dev->of_node, "regulators");
+       struct device_node *node __free(device_node) =
+               of_get_child_by_name(chip->dev->of_node, "regulators");
        if (!node) {
                dev_err(chip->dev, "regulators node not found\n");
                return -ENODEV;
 
        ret = of_regulator_match(chip->dev, node, matches,
                                 chip->info->num_outputs);
-       of_node_put(node);
        if (ret < 0) {
                dev_err(chip->dev, "Failed to match regulators\n");
                return -EINVAL;