Should check the return value of of_get_regulator_init_data before
using it.

Cc: Liam Girdwood <lgirdw...@gmail.com>
Cc: Mark Brown <broo...@kernel.org>
Cc: Shawn Guo <shawn...@kernel.org>
Cc: Sascha Hauer <ker...@pengutronix.de>
Cc: Robin Gong <yibin.g...@nxp.com>
Signed-off-by: Dong Aisheng <aisheng.d...@nxp.com>
---
 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