[PATCH] regulator: anatop: check return value of of_get_regulator_init_data

From: Dong Aisheng
Date: Tue Apr 11 2017 - 21:58:42 EST


Should check the return value of of_get_regulator_init_data before
using it.

Signed-off-by: Dong Aisheng <aisheng.dong@xxxxxxx>
Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
---
drivers/regulator/anatop-regulator.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index 3a6d0290c54c..aa93f462ac6e 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -200,6 +200,9 @@ static int anatop_regulator_probe(struct platform_device *pdev)
rdesc->owner = THIS_MODULE;

initdata = of_get_regulator_init_data(dev, np, rdesc);
+ if (!initdata)
+ return -ENOMEM;
+
initdata->supply_regulator = "vin";
sreg->initdata = initdata;

--
2.11.0