rdesc->name/regulator-name is optional according to standard regulator
binding doc. Use it conditionally to avoid a kernel NULL point crash.

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/anatop-regulator.c 
b/drivers/regulator/anatop-regulator.c
index 19eb1f4..6da0b20 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -298,7 +298,7 @@ static int anatop_regulator_probe(struct platform_device 
*pdev)
                 * a sane default until imx6-cpufreq was probed and changes the
                 * voltage to the correct value. In this case we set 1.25V.
                 */
-               if (!sreg->sel && !strcmp(rdesc->name, "vddpu"))
+               if (!sreg->sel && rdesc->name && !strcmp(rdesc->name, "vddpu"))
                        sreg->sel = 22;
 
                if (!sreg->bypass && !sreg->sel) {
-- 
2.7.4

Reply via email to