* [PATCH] regulator: lp872x: Return -EINVAL if pdata is NULL
@ 2012-06-20 8:13 Axel Lin
2012-06-20 10:18 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-06-20 8:13 UTC (permalink / raw)
To: linux-kernel; +Cc: Milo(Woogyom) Kim, Liam Girdwood, Mark Brown
Return -EINVAL if pdata is NULL, otherwise we have NULL dereference bug.
This patch also moves the code checking pdata earlier in lp872x_probe.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/lp872x.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c
index d51d098..e8f54ef 100644
--- a/drivers/regulator/lp872x.c
+++ b/drivers/regulator/lp872x.c
@@ -785,11 +785,6 @@ static int lp872x_config(struct lp872x *lp)
struct lp872x_platform_data *pdata = lp->pdata;
int ret;
- if (!pdata) {
- dev_warn(lp->dev, "no platform data\n");
- return 0;
- }
-
if (!pdata->update_config)
return 0;
@@ -889,6 +884,11 @@ static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
[LP8725] = LP8725_NUM_REGULATORS,
};
+ if (!pdata) {
+ dev_warn(&cl->dev, "no platform data\n");
+ return -EINVAL;
+ }
+
lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL);
if (!lp)
goto err_mem;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: lp872x: Return -EINVAL if pdata is NULL
2012-06-20 8:13 [PATCH] regulator: lp872x: Return -EINVAL if pdata is NULL Axel Lin
@ 2012-06-20 10:18 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2012-06-20 10:18 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Milo(Woogyom) Kim, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 276 bytes --]
On Wed, Jun 20, 2012 at 04:13:15PM +0800, Axel Lin wrote:
> Return -EINVAL if pdata is NULL, otherwise we have NULL dereference bug.
> This patch also moves the code checking pdata earlier in lp872x_probe.
Applied, thanks. We should really not be insisting on pdata though.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-06-20 10:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-20 8:13 [PATCH] regulator: lp872x: Return -EINVAL if pdata is NULL Axel Lin
2012-06-20 10:18 ` Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.