linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] regulator: Fix the error handling if create_regulator fails
@ 2011-12-29  9:02 Axel Lin
  2011-12-29  9:03 ` [PATCH 2/2] regulator: Fix checking return value of create_regulator Axel Lin
  2011-12-29 10:44 ` [PATCH 1/2] regulator: Fix the error handling if create_regulator fails Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2011-12-29  9:02 UTC (permalink / raw)
  To: linux-kernel; +Cc: Liam Girdwood, Mark Brown

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 <axel.lin@gmail.com>
---
 drivers/regulator/core.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index dbdebed6..fb6ea9b 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1282,6 +1282,7 @@ found:
 	if (regulator == NULL) {
 		regulator = ERR_PTR(-ENOMEM);
 		module_put(rdev->owner);
+		goto out;
 	}
 
 	rdev->open_count++;
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] regulator: Fix checking return value of create_regulator
  2011-12-29  9:02 [PATCH 1/2] regulator: Fix the error handling if create_regulator fails Axel Lin
@ 2011-12-29  9:03 ` Axel Lin
  2011-12-29 10:44 ` [PATCH 1/2] regulator: Fix the error handling if create_regulator fails Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Axel Lin @ 2011-12-29  9:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: Liam Girdwood, Mark Brown

create_regulator() returns NULL on fail.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/core.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index fb6ea9b..5e43906 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -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;
 	}
 
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] regulator: Fix the error handling if create_regulator fails
  2011-12-29  9:02 [PATCH 1/2] regulator: Fix the error handling if create_regulator fails Axel Lin
  2011-12-29  9:03 ` [PATCH 2/2] regulator: Fix checking return value of create_regulator Axel Lin
@ 2011-12-29 10:44 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2011-12-29 10:44 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Liam Girdwood

On Thu, Dec 29, 2011 at 05:02:08PM +0800, Axel Lin wrote:
> 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.

Applied both, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-29 10:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-29  9:02 [PATCH 1/2] regulator: Fix the error handling if create_regulator fails Axel Lin
2011-12-29  9:03 ` [PATCH 2/2] regulator: Fix checking return value of create_regulator Axel Lin
2011-12-29 10:44 ` [PATCH 1/2] regulator: Fix the error handling if create_regulator fails Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).