Skip to content

Commit

Permalink
regulator: core: Rely on regulator_dev_release to free constraints
Browse files Browse the repository at this point in the history
commit 6333ef4 upstream.

As we now free the constraints in regulator_dev_release we will still
call free on the constraints pointer even if we went down an error
path in regulator_register, because it is only allocated after the
device_register. As such we no longer need to free rdev->constraints
on the error paths, so this patch removes said frees.

Fixes: 29f5f48 ("regulator: core: Move more deallocation into class unregister")
Signed-off-by: Charles Keepax <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Lee Jones <[email protected]>
Change-Id: Idef9de1452b1d4cca2b1b4bf08fc45c06c267549
  • Loading branch information
charleskeepax authored and Lee Jones committed May 30, 2020
1 parent 3fa420e commit cc5484b
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1000,32 +1000,31 @@ static int set_machine_constraints(struct regulator_dev *rdev,

ret = machine_constraints_voltage(rdev, rdev->constraints);
if (ret != 0)
goto out;
return ret;

ret = machine_constraints_current(rdev, rdev->constraints);
if (ret != 0)
goto out;
return ret;

/* do we need to setup our suspend state */
if (rdev->constraints->initial_state) {
ret = suspend_prepare(rdev, rdev->constraints->initial_state);
if (ret < 0) {
rdev_err(rdev, "failed to set suspend state\n");
goto out;
return ret;
}
}

if (rdev->constraints->initial_mode) {
if (!ops->set_mode) {
rdev_err(rdev, "no set_mode operation\n");
ret = -EINVAL;
goto out;
return -EINVAL;
}

ret = ops->set_mode(rdev, rdev->constraints->initial_mode);
if (ret < 0) {
rdev_err(rdev, "failed to set initial mode: %d\n", ret);
goto out;
return ret;
}
}

Expand All @@ -1036,7 +1035,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
ret = _regulator_do_enable(rdev);
if (ret < 0 && ret != -EINVAL) {
rdev_err(rdev, "failed to enable\n");
goto out;
return ret;
}
}

Expand All @@ -1045,16 +1044,12 @@ static int set_machine_constraints(struct regulator_dev *rdev,
ret = ops->set_ramp_delay(rdev, rdev->constraints->ramp_delay);
if (ret < 0) {
rdev_err(rdev, "failed to set ramp_delay\n");
goto out;
return ret;
}
}

print_constraints(rdev);
return 0;
out:
kfree(rdev->constraints);
rdev->constraints = NULL;
return ret;
}

/**
Expand Down Expand Up @@ -3749,7 +3744,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
if (rdev->supply)
_regulator_put(rdev->supply);
regulator_ena_gpio_free(rdev);
kfree(rdev->constraints);

wash:
device_unregister(&rdev->dev);
/* device core frees rdev */
Expand Down

0 comments on commit cc5484b

Please sign in to comment.