regulator: Avoid potential NULL dereference in reg_fixed_voltage_probe()
PATCH v2 1/1 regulator: Avoid potential NULL dereference in reg_fixed_voltage_probe()
of_get_fixed_voltage_config() may return NULL, return -ENOMEM in this case so we don't dereference NULL pointer.
Signed-off-by Axel Lin <[email protected]>
--- drivers/regulator/fixed.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/regulator/fixed.c +6 -1
@@ -163,12 +163,17 @@ static struct regulator_ops fixed_voltage_ops = {static int __devinit reg_fixed_voltage_probe (struct platform_device *pdev) { -struct fixed_voltage_config *config = pdev->dev.platform_data; +struct fixed_voltage_config *config;struct fixed_voltage_data *drvdata;int ret;if (pdev->dev.of_node) config =of_get_fixed_voltage_config (&pdev->dev); +else + config = pdev->dev.platform_data; + +if (!config) +return -ENOMEM ; drvdata =kzalloc (sizeof (struct fixed_voltage_data ),GFP_KERNEL );if (drvdata ==NULL ) {
Signature · 1 line
1.7.5.4
Mark Brown
AppliedQuoted 4 lines · Axel Lin
of_get_fixed_voltage_config()may return NULL, return-ENOMEMin this case so we don't dereference NULL pointer.Signed-off-by Axel Lin <[email protected]>
Applied, thanks.