Patch "regulator: of: Implement the unwind path of of_regulator_match()" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    regulator: of: Implement the unwind path of of_regulator_match()

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     regulator-of-implement-the-unwind-path-of-of_regulat.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e93b7637a341d6e3bba9c2d67658c6571241cbd6
Author: Joe Hattori <joe@xxxxxxxxxxxxxxxxxxxxx>
Date:   Sat Jan 4 17:04:53 2025 +0900

    regulator: of: Implement the unwind path of of_regulator_match()
    
    [ Upstream commit dddca3b2fc676113c58b04aaefe84bfb958ac83e ]
    
    of_regulator_match() does not release the OF node reference in the error
    path, resulting in an OF node leak. Therefore, call of_node_put() on the
    obtained nodes before returning the EINVAL error.
    
    Since it is possible that some drivers call this function and do not
    exit on failure, such as s2mps11_pmic_driver, clear the init_data and
    of_node in the error path.
    
    This was reported by an experimental verification tool that I am
    developing. As I do not have access to actual devices nor the QEMU board
    configuration to test drivers that call this function, no runtime test
    was able to be performed.
    
    Fixes: 1c8fa58f4750 ("regulator: Add generic DT parsing for regulators")
    Signed-off-by: Joe Hattori <joe@xxxxxxxxxxxxxxxxxxxxx>
    Link: https://patch.msgid.link/20250104080453.2153592-1-joe@xxxxxxxxxxxxxxxxxxxxx
    Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 5d844697c7b68..d1e69470137cf 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -377,7 +377,7 @@ int of_regulator_match(struct device *dev, struct device_node *node,
 					"failed to parse DT for regulator %pOFn\n",
 					child);
 				of_node_put(child);
-				return -EINVAL;
+				goto err_put;
 			}
 			match->of_node = of_node_get(child);
 			count++;
@@ -386,6 +386,18 @@ int of_regulator_match(struct device *dev, struct device_node *node,
 	}
 
 	return count;
+
+err_put:
+	for (i = 0; i < num_matches; i++) {
+		struct of_regulator_match *match = &matches[i];
+
+		match->init_data = NULL;
+		if (match->of_node) {
+			of_node_put(match->of_node);
+			match->of_node = NULL;
+		}
+	}
+	return -EINVAL;
 }
 EXPORT_SYMBOL_GPL(of_regulator_match);
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux