Skip to contentSkip to conversation

regulator: lp872x: Return -EINVAL if pdata is NULL

PATCH Applied Axel Lin 2 participants 2 messages Jun 20, 2012 Voltage and current regulator framework

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 regulator: lp872x: Return -EINVAL if pdata is NULL

Return -EINVAL if pdata is NULL, otherwise we have NULL dereference bug. This patch also moves the code checking pdata earlier in lp872x_probe.

---
 drivers/regulator/lp872x.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/regulator/lp872x.c +5 -5
index d51d098..e8f54ef 100644
@@ -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;
Signature · 1 line
1.7.9.5
Applied
#1 lore raw
Quoted 2 lines · Axel Lin

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.