Should check the return value of of_get_regulator_init_data before
using it.

Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Robin Gong <[email protected]>
Signed-off-by: Dong Aisheng <[email protected]>
---
 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 b041f27..46b9c2c 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.7.4

Reply via email to