regulator: Fix the error handling if create_regulator fails
PATCH 1/2 regulator: Fix the error handling if create_regulator fails
In the case of create_regulator() fails, goto the error path immediately. It does not make sense to update rdev->open_count if create_regulator fails.
Signed-off-by Axel Lin <[email protected]>
--- drivers/regulator/core.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/regulator/core.c +1 -0
@@ -1282,6 +1282,7 @@ found:if (regulator ==NULL ) { regulator =ERR_PTR (-ENOMEM );module_put (rdev->owner); + goto out; } rdev->open_count++;
Signature · 1 line
1.7.5.4
PATCH 2/2 regulator: Fix checking return value of create_regulator
create_regulator() returns NULL on fail.
Signed-off-by Axel Lin <[email protected]>
--- drivers/regulator/core.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/regulator/core.c +2 -3
@@ -985,9 +985,8 @@ static int set_supply(struct regulator_dev *rdev,rdev_info (rdev,"supplied by %s\n" ,rdev_get_name (supply_rdev)); rdev->supply =create_regulator (supply_rdev, &rdev->dev,"SUPPLY" ); -if (IS_ERR (rdev->supply)) { - err =PTR_ERR (rdev->supply); - rdev->supply =NULL ; +if (rdev->supply ==NULL ) { + err = -ENOMEM ;return err; }
Signature · 1 line
1.7.5.4
Mark Brown
AppliedQuoted 2 lines · Axel Lin
In the case of
create_regulator()fails, goto the error path immediately. It does not make sense to updaterdev->open_countifcreate_regulatorfails.
Applied both, thanks.