From: Guenter Roeck <linux@roeck-us.net>
To: Dan Carpenter <dan.carpenter@oracle.com>,
MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: Chanwoo Choi <cw00.choi@samsung.com>,
Sebastian Reichel <sre@kernel.org>, Chen-Yu Tsai <wens@csie.org>,
Hans de Goede <hdegoede@redhat.com>,
Felipe Balbi <balbi@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
linux-usb@vger.kernel.org, linux-omap@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] extcon: fix extcon_get_extcon_dev() error handling
Date: Thu, 18 Nov 2021 06:22:58 -0800 [thread overview]
Message-ID: <a33fc3d7-a389-a805-0ef9-4b90de1d3d89@roeck-us.net> (raw)
In-Reply-To: <20211118113026.GG1147@kili>
On 11/18/21 3:32 AM, Dan Carpenter wrote:
> 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@oracle.com>
> ---
> 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);
Why does the code not need to return -EPROBE_DEFER ? The description states
that NULL is returned in that situation. Doesn't that mean that defer situations
are no longer handled with this patch in place ?
Also, with this patch in place, the code will no longer work if extcon is disabled,
because extcon_get_extcon_dev() will return -ENODEV and the above code will bail out.
The behavior of the code wasn't optimal in that case (it would wait until timeout
in tcpm_get_current_limit() before returning), but at least it didn't fail.
Thanks,
Guenter
next prev parent reply other threads:[~2021-11-18 14:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-18 11:32 Dan Carpenter
2021-11-18 12:22 ` Sebastian Reichel
2021-11-18 12:23 ` Hans de Goede
2021-11-18 13:13 ` Heikki Krogerus
2021-11-18 14:22 ` Guenter Roeck [this message]
2021-11-18 14:51 ` Dan Carpenter
2021-11-18 18:16 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a33fc3d7-a389-a805-0ef9-4b90de1d3d89@roeck-us.net \
--to=linux@roeck-us.net \
--cc=balbi@kernel.org \
--cc=cw00.choi@samsung.com \
--cc=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=sre@kernel.org \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®