mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-19 03:31:25 +00:00
regulator: fixed: Prevent NULL pointer dereference when !CONFIG_OF
Use of_device_get_match_data which has NULL test for match before dereference match->data. Add NULL test for drvtype so it still works for fixed_voltage_ops when !CONFIG_OF. Signed-off-by: Axel Lin <axel.lin@ingics.com> Reviewed-by: Philippe Schenker <philippe.schenker@toradex.com> Link: https://lore.kernel.org/r/20190922022928.28355-1-axel.lin@ingics.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
f8970d341e
commit
1d6db22ff7
@ -144,8 +144,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
|
|||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct fixed_voltage_config *config;
|
struct fixed_voltage_config *config;
|
||||||
struct fixed_voltage_data *drvdata;
|
struct fixed_voltage_data *drvdata;
|
||||||
const struct fixed_dev_type *drvtype =
|
const struct fixed_dev_type *drvtype = of_device_get_match_data(dev);
|
||||||
of_match_device(dev->driver->of_match_table, dev)->data;
|
|
||||||
struct regulator_config cfg = { };
|
struct regulator_config cfg = { };
|
||||||
enum gpiod_flags gflags;
|
enum gpiod_flags gflags;
|
||||||
int ret;
|
int ret;
|
||||||
@ -177,7 +176,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
|
|||||||
drvdata->desc.type = REGULATOR_VOLTAGE;
|
drvdata->desc.type = REGULATOR_VOLTAGE;
|
||||||
drvdata->desc.owner = THIS_MODULE;
|
drvdata->desc.owner = THIS_MODULE;
|
||||||
|
|
||||||
if (drvtype->has_enable_clock) {
|
if (drvtype && drvtype->has_enable_clock) {
|
||||||
drvdata->desc.ops = &fixed_voltage_clkenabled_ops;
|
drvdata->desc.ops = &fixed_voltage_clkenabled_ops;
|
||||||
|
|
||||||
drvdata->enable_clock = devm_clk_get(dev, NULL);
|
drvdata->enable_clock = devm_clk_get(dev, NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user