]> Git Repo - linux.git/commitdiff
regulator: da9063: fix null pointer deref with partial DT config
authorMartin Fuzzey <[email protected]>
Fri, 16 Jun 2023 14:36:28 +0000 (16:36 +0200)
committerMark Brown <[email protected]>
Mon, 17 Jul 2023 05:15:18 +0000 (06:15 +0100)
When some of the da9063 regulators do not have corresponding DT nodes
a null pointer dereference occurs on boot because such regulators have
no init_data causing the pointers calculated in
da9063_check_xvp_constraints() to be invalid.

Do not dereference them in this case.

Fixes: b8717a80e6ee ("regulator: da9063: implement setter for voltage monitoring")
Signed-off-by: Martin Fuzzey <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
drivers/regulator/da9063-regulator.c

index c5dd77be558b6becf2ee37285e7590037e46e1fc..dfd5ec9f75c90fd69cd2c78aaa31e04284d9acf6 100644 (file)
@@ -778,6 +778,9 @@ static int da9063_check_xvp_constraints(struct regulator_config *config)
        const struct notification_limit *uv_l = &constr->under_voltage_limits;
        const struct notification_limit *ov_l = &constr->over_voltage_limits;
 
+       if (!config->init_data) /* No config in DT, pointers will be invalid */
+               return 0;
+
        /* make sure that only one severity is used to clarify if unchanged, enabled or disabled */
        if ((!!uv_l->prot + !!uv_l->err + !!uv_l->warn) > 1) {
                dev_err(config->dev, "%s: at most one voltage monitoring severity allowed!\n",
This page took 0.062426 seconds and 4 git commands to generate.