Re: [PATCH] regulator: core: Resolve supply name earlier to prevent double-init

From: Mark Brown
Date: Thu Jul 21 2022 - 11:01:35 EST


On Fri, Jul 15, 2022 at 10:32:16PM +0200, Christian Kohlschütter wrote:
> Previously, an unresolved regulator supply reference upon calling
> regulator_register on an always-on or boot-on regulator caused
> set_machine_constraints to be called twice.

One small thing below but otherwise I think this should be fine, however
since we're very near the merge window I'd rather hold off any apply at
-rc1, just to give more time for things to get tested.

> - /* set regulator constraints */
> - if (init_data)
> - rdev->constraints = kmemdup(&init_data->constraints,
> - sizeof(*rdev->constraints),
> - GFP_KERNEL);
> - else
> - rdev->constraints = kzalloc(sizeof(*rdev->constraints),
> - GFP_KERNEL);
> if (!rdev->constraints) {
> ret = -ENOMEM;
> goto wash;
> }

The check for allocation failure should get pulled earlier in the
function along with the allocation, no sense in doing any of the other
work if we're going to fail.

Attachment: signature.asc
Description: PGP signature