2024-04-29 14:51:09

by Michał Mirosław

[permalink] [raw]
Subject: [PATCH v2 04/12] regulator/core: regulator_bulk_get: remove redundant NULL stores

On error, callers of regulator_bulk_get() pass the error up and don't
use the pointers in consumers[]. The function is documented to release
all regulators if any request fails.

Note: if an i-th regulator_get() failed only the i-th pointer was
cleared. This is another suggestion that the clearing was unnecessary.

Signed-off-by: Michał Mirosław <[email protected]>
---
drivers/regulator/core.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 3d7147fabbed..a1573a7ff2b2 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -4872,11 +4872,7 @@ static int _notifier_call_chain(struct regulator_dev *rdev,
int _regulator_bulk_get(struct device *dev, int num_consumers,
struct regulator_bulk_data *consumers, enum regulator_get_type get_type)
{
- int i;
- int ret;
-
- for (i = 0; i < num_consumers; i++)
- consumers[i].consumer = NULL;
+ int ret, i;

for (i = 0; i < num_consumers; i++) {
consumers[i].consumer = _regulator_get(dev,
@@ -4885,7 +4881,6 @@ int _regulator_bulk_get(struct device *dev, int num_consumers,
ret = dev_err_probe(dev, PTR_ERR(consumers[i].consumer),
"Failed to get supply '%s'",
consumers[i].supply);
- consumers[i].consumer = NULL;
goto err;
}

--
2.39.2



2024-04-29 16:03:09

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v2 04/12] regulator/core: regulator_bulk_get: remove redundant NULL stores

On Mon, Apr 29, 2024 at 04:45:28PM +0200, Michał Mirosław wrote:
> On error, callers of regulator_bulk_get() pass the error up and don't
> use the pointers in consumers[]. The function is documented to release
> all regulators if any request fails.

This doesn't seem good from a robustness point of view and should be
nowhere near a fast path.


Attachments:
(No filename) (354.00 B)
signature.asc (499.00 B)
Download all attachments

2024-05-01 10:55:43

by Michał Mirosław

[permalink] [raw]
Subject: Re: [PATCH v2 04/12] regulator/core: regulator_bulk_get: remove redundant NULL stores

On Tue, Apr 30, 2024 at 01:01:28AM +0900, Mark Brown wrote:
> On Mon, Apr 29, 2024 at 04:45:28PM +0200, Micha? Miros?aw wrote:
> > On error, callers of regulator_bulk_get() pass the error up and don't
> > use the pointers in consumers[]. The function is documented to release
> > all regulators if any request fails.
>
> This doesn't seem good from a robustness point of view and should be
> nowhere near a fast path.

I take it you'd prefer to have the function fixed to clear the other
pointers? I'll do that in the v3 then.

Best Regards
Micha? Miros?aw