regulator: Fix possible nullpointer dereference in regulator_enable()

A patch from »regulator: Fix possible nullpointer dereference in regulator_enable()« in state Mainline for linux-kernel

From: Heiko Stuebner <heiko@...> Date: Sun, 18 Sep 2011 16:54:50 +0200

Commit-Message

In the case where _regulator_enable returns an error it was not checked if a supplying regulator exists before trying to disable it, leading to a null pointer-dereference if no supplying regulator existed. Signed-off-by: Heiko Stuebner <heiko@...> Acked-by: Mark Brown <broonie@...>

Patch-Comment

no changes, except adding the ack from Mark Brown and including the relevant (and forgotten in the first try) LKML drivers/regulator/core.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)

Statistics

  • 1 lines added
  • 1 lines removed

Changes

--------------------------- drivers/regulator/core.c ---------------------------
index 026f3d4..c9dd19c 100644
@@ -1425,7 +1425,7 @@ int regulator_enable(struct regulator *regulator)
ret = _regulator_enable(rdev);
mutex_unlock(&rdev->mutex);
- if (ret != 0)
+ if (ret != 0 && rdev->supply)
regulator_disable(rdev->supply);
return ret;
 
 

Recent Patches

About Us

Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum vel, tempor at, varius non, purus. Mauris vitae nisl nec metus placerat consectetuer.

Read More...