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 v2] extcon: fix extcon_get_extcon_dev() error handling
Date: Tue, 23 Nov 2021 06:48:41 -0800 [thread overview]
Message-ID: <a29fa1be-1df6-d43d-9a6d-90db7587af55@roeck-us.net> (raw)
In-Reply-To: <20211123083925.GA3277@kili>
On 11/23/21 12:43 AM, Dan Carpenter wrote:
> The extcon_get_extcon_dev() function returns error pointers on error,
> NULL when it's a -EPROBE_DEFER defer situation, and ERR_PTR(-ENODEV)
> when the CONFIG_EXTCON option is disabled. This is very complicated for
> the callers to handle and a number of them had bugs that would lead to
> an Oops.
>
> In real life, there are two things which prevented crashes. First,
> error pointers would only be returned if there was bug in the caller
> where they passed a NULL "extcon_name" and none of them do that.
> Second, only two out of the eight drivers will build when CONFIG_EXTCON
> is disabled.
>
> The normal way to write this would be to return -EPROBE_DEFER directly
> when appropriate and return NULL when CONFIG_EXTCON is disabled. Then
> the error handling is simple and just looks like:
>
> dev->edev = extcon_get_extcon_dev(acpi_dev_name(adev));
> if (IS_ERR(dev->edev))
> return PTR_ERR(dev->edev);
>
> For the two drivers which can build with CONFIG_EXTCON disabled, then
> extcon_get_extcon_dev() will now return NULL which is not treated as an
> error and the probe will continue successfully. Those two drivers are
> "typec_fusb302" and "max8997-battery". In the original code, the
> typec_fusb302 driver had an 800ms hang in tcpm_get_current_limit() but
> now that function is a no-op. For the max8997-battery driver everything
> should continue working as is.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
next prev parent reply other threads:[~2021-11-23 14:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20211123084357epcas1p14833147710153f9606f14941ac8b0d96@epcas1p1.samsung.com>
2021-11-23 8:43 ` [PATCH v2] extcon: fix extcon_get_extcon_dev() error handling Dan Carpenter
2021-11-23 14:14 ` Hans de Goede
2021-11-23 14:48 ` Guenter Roeck [this message]
2021-11-23 15:20 ` Heikki Krogerus
2021-12-16 6:39 ` Chanwoo Choi
2021-12-16 7:52 ` Dan Carpenter
2021-12-16 8:24 ` Chanwoo Choi
2021-12-16 8:05 ` Dan Carpenter
2021-12-16 8:38 ` Chanwoo Choi
2021-12-16 15:59 ` Dan Carpenter
2021-12-17 1:31 ` Chanwoo Choi
2021-12-16 9:08 ` Hans de Goede
2021-12-17 6:28 ` [PATCH v3] " Dan Carpenter
2021-12-20 1:20 ` Chanwoo Choi
2022-02-03 5:24 ` Chanwoo Choi
2022-02-16 1:12 ` Chanwoo Choi
2022-01-03 17:46 ` Sebastian Reichel
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=a29fa1be-1df6-d43d-9a6d-90db7587af55@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