Commit 348359e7 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Greg Kroah-Hartman

usb: typec: nb7vpq904m: Add an error handling path in nb7vpq904m_probe()

In case of error in the nb7vpq904m_probe() probe function, some resources
need to be freed, as already done in the remove function.

Add the missing error handling path and adjust code accordingly.

Fixes: 88d8f3ac ("usb: typec: add support for the nb7vpq904m Type-C Linear Redriver")
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
Acked-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/9118954765821ea9f1179883602b4eca63e91749.1689716381.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5a5ccd61
...@@ -463,16 +463,18 @@ static int nb7vpq904m_probe(struct i2c_client *client) ...@@ -463,16 +463,18 @@ static int nb7vpq904m_probe(struct i2c_client *client)
ret = nb7vpq904m_register_bridge(nb7); ret = nb7vpq904m_register_bridge(nb7);
if (ret) if (ret)
return ret; goto err_disable_gpio;
sw_desc.drvdata = nb7; sw_desc.drvdata = nb7;
sw_desc.fwnode = dev->fwnode; sw_desc.fwnode = dev->fwnode;
sw_desc.set = nb7vpq904m_sw_set; sw_desc.set = nb7vpq904m_sw_set;
nb7->sw = typec_switch_register(dev, &sw_desc); nb7->sw = typec_switch_register(dev, &sw_desc);
if (IS_ERR(nb7->sw)) if (IS_ERR(nb7->sw)) {
return dev_err_probe(dev, PTR_ERR(nb7->sw), ret = dev_err_probe(dev, PTR_ERR(nb7->sw),
"Error registering typec switch\n"); "Error registering typec switch\n");
goto err_disable_gpio;
}
retimer_desc.drvdata = nb7; retimer_desc.drvdata = nb7;
retimer_desc.fwnode = dev->fwnode; retimer_desc.fwnode = dev->fwnode;
...@@ -480,12 +482,21 @@ static int nb7vpq904m_probe(struct i2c_client *client) ...@@ -480,12 +482,21 @@ static int nb7vpq904m_probe(struct i2c_client *client)
nb7->retimer = typec_retimer_register(dev, &retimer_desc); nb7->retimer = typec_retimer_register(dev, &retimer_desc);
if (IS_ERR(nb7->retimer)) { if (IS_ERR(nb7->retimer)) {
typec_switch_unregister(nb7->sw); ret = dev_err_probe(dev, PTR_ERR(nb7->retimer),
return dev_err_probe(dev, PTR_ERR(nb7->retimer), "Error registering typec retimer\n");
"Error registering typec retimer\n"); goto err_switch_unregister;
} }
return 0; return 0;
err_switch_unregister:
typec_switch_unregister(nb7->sw);
err_disable_gpio:
gpiod_set_value(nb7->enable_gpio, 0);
regulator_disable(nb7->vcc_supply);
return ret;
} }
static void nb7vpq904m_remove(struct i2c_client *client) static void nb7vpq904m_remove(struct i2c_client *client)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment