From: Johan Hovold <johan+linaro@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J . Wysocki " <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Johan Hovold <johan+linaro@kernel.org>
Subject: [PATCH] component: do not try to unbind unbound components
Date: Fri, 28 Feb 2025 09:18:24 +0100 [thread overview]
Message-ID: <20250228081824.4640-1-johan+linaro@kernel.org> (raw)
Error handling is apparently hard and driver authors often get it wrong.
Continue to warn but do not try to unbind components that have never
been bound in order to avoid crashing systems where such a buggy
teardown path is hit.
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
I've been sitting on this one for too long now after I ran into such an
issue while fixing up the MDM DRM driver which triggered all sorts
problems on probe deferral.
Here's a recent example of where a return here would have a avoided a
double free:
https://lore.kernel.org/lkml/6089322f3d5f2e56f4d7a5899d70da2bc45978f7.1702509741.git.soyer@irl.hu/
Arguably, crashing the system is more noticeable, but not very nice for
users.
Johan
drivers/base/component.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/base/component.c b/drivers/base/component.c
index 741497324d78..3faa92d26be3 100644
--- a/drivers/base/component.c
+++ b/drivers/base/component.c
@@ -572,7 +572,8 @@ EXPORT_SYMBOL_GPL(component_master_del);
static void component_unbind(struct component *component,
struct aggregate_device *adev, void *data)
{
- WARN_ON(!component->bound);
+ if (WARN_ON(!component->bound))
+ return;
if (component->ops && component->ops->unbind)
component->ops->unbind(component->dev, adev->parent, data);
--
2.45.3
reply other threads:[~2025-02-28 8:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250228081824.4640-1-johan+linaro@kernel.org \
--to=johan+linaro@kernel.org \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.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®