The extcon_get_extcon_dev() function returns error pointers on error[ ... ]
and NULL when it's a -EPROBE_DEFER defer situation. There are eight
callers and only two of them handled this correctly. In the other
callers an error pointer return would lead to a crash.
What prevents crashes is that errors can only happen in the case of
a bug in the caller or if CONFIG_EXTCON is disabled. Six out of
eight callers use the Kconfig to either depend on or select
CONFIG_EXTCON. Thus the real life impact of these bugs is tiny.
Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
---
The two callers where the drivers can be built without CONFIG_EXTCON
are TYPEC_FUSB302 and CHARGER_MAX8997.
diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c
index 7a2a17866a82..8594b59bd527 100644
--- a/drivers/usb/typec/tcpm/fusb302.c
+++ b/drivers/usb/typec/tcpm/fusb302.c
@@ -1706,8 +1706,8 @@ static int fusb302_probe(struct i2c_client *client,
*/
if (device_property_read_string(dev, "linux,extcon-name", &name) == 0) {
chip->extcon = extcon_get_extcon_dev(name);
- if (!chip->extcon)
- return -EPROBE_DEFER;
+ if (IS_ERR(chip->extcon))
+ return PTR_ERR(chip->extcon);