mfd: max8998: Fix potential NULL pointer dereference

if 'max8998_i2c_parse_dt_pdata() fails (when out of memory), a NULL
pointer dereference will occur in the error handling code.

Return directly instead.

Fixes: ee999fb3f17f("mfd: max8998: Add support for Device Tree")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
Christophe JAILLET 2017-07-05 07:50:54 +02:00 committed by Lee Jones
parent 0953075112
commit 2042f3c29f
1 changed files with 2 additions and 4 deletions

View File

@ -192,10 +192,8 @@ static int max8998_i2c_probe(struct i2c_client *i2c,
if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) { if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) {
pdata = max8998_i2c_parse_dt_pdata(&i2c->dev); pdata = max8998_i2c_parse_dt_pdata(&i2c->dev);
if (IS_ERR(pdata)) { if (IS_ERR(pdata))
ret = PTR_ERR(pdata); return PTR_ERR(pdata);
goto err;
}
} }
i2c_set_clientdata(i2c, max8998); i2c_set_clientdata(i2c, max8998);