Re: [PATCH] regulator: da9063: fix null pointer deref with partial DT config

From: Mark Brown
Date: Fri Jun 16 2023 - 10:59:16 EST


On Fri, Jun 16, 2023 at 04:36:28PM +0200, Martin Fuzzey wrote:

> 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;
> +

We already dereferenced above when we were initialising the variables,
the compiler might still generate dereferences before it does the checks
here.

> /* 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",
> --
> 2.25.1
>

Attachment: signature.asc
Description: PGP signature