All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@misterjones.org>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, "Robert Święcki" <robert@swiecki.net>,
	"Mikhail Gavrilov" <mikhail.v.gavrilov@gmail.com>
Subject: Re: [PATCH 1/2] usb: typec: Only attempt to link USB ports if there is fwnode
Date: Mon, 24 Jan 2022 16:26:48 +0000	[thread overview]
Message-ID: <fc2ed8eace5a5d6f42b6e45b38d79bb6@misterjones.org> (raw)
In-Reply-To: <20220124090228.41396-2-heikki.krogerus@linux.intel.com>

On 2022-01-24 09:02, Heikki Krogerus wrote:
> The code that creates the links to the USB ports attached to
> a connector inside the system assumed that the ACPI nodes
> (fwnodes) always exist for the connectors, but it can not do
> that.
> 
> There is no guarantee that every USB Type-C connector has
> ACPI device node representing it in the ACPI tables, and
> even if there are the nodes in the ACPI tables, the _STA
> method in those nodes may still return 0 (which means the
> device does not exist from ACPI PoW).
> 
> This fixes NULL pointer dereference that happens if the
> nodes are missing.
> 
> Reported-and-tested-by: Robert Święcki <robert@swiecki.net>
> Reported-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
> Fixes: 730b49aac426 ("usb: typec: port-mapper: Convert to the
> component framework")
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
>  drivers/usb/typec/port-mapper.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/port-mapper.c 
> b/drivers/usb/typec/port-mapper.c
> index 07d307418b470..b6e0c6acc628c 100644
> --- a/drivers/usb/typec/port-mapper.c
> +++ b/drivers/usb/typec/port-mapper.c
> @@ -56,6 +56,9 @@ int typec_link_ports(struct typec_port *con)
>  {
>  	struct each_port_arg arg = { .port = con, .match = NULL };
> 
> +	if (!has_acpi_companion(&con->dev))
> +		return 0;
> +
>  	bus_for_each_dev(&acpi_bus_type, NULL, &arg, typec_port_match);
> 
>  	/*
> @@ -74,5 +77,6 @@ int typec_link_ports(struct typec_port *con)
> 
>  void typec_unlink_ports(struct typec_port *con)
>  {
> -	component_master_del(&con->dev, &typec_aggregate_ops);
> +	if (has_acpi_companion(&con->dev))
> +		component_master_del(&con->dev, &typec_aggregate_ops);
>  }

This fixes an ugly Oops on the Apple M1. So FWIW:

Acked-by: Marc Zyngier <maz@kernel.org>
Tested-by: Marc Zyngier <maz@kernel.org>

         M.
-- 
Who you jivin' with that Cosmik Debris?

  reply	other threads:[~2022-01-24 16:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24  9:02 [PATCH 0/2] usb: typec: Two fixes Heikki Krogerus
2022-01-24  9:02 ` [PATCH 1/2] usb: typec: Only attempt to link USB ports if there is fwnode Heikki Krogerus
2022-01-24 16:26   ` Marc Zyngier [this message]
2022-01-24  9:02 ` [PATCH 2/2] usb: typec: Don't try to register component master without components Heikki Krogerus

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=fc2ed8eace5a5d6f42b6e45b38d79bb6@misterjones.org \
    --to=maz@misterjones.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=mikhail.v.gavrilov@gmail.com \
    --cc=robert@swiecki.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.