]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
usb: ucsi: Fix NULL pointer deref in ucsi_connector_change()
authorHans de Goede <hdegoede@redhat.com>
Wed, 8 Mar 2023 15:42:42 +0000 (16:42 +0100)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Wed, 17 May 2023 11:33:38 +0000 (13:33 +0200)
commitdd9e47aaebfd5ad6286e7bfdb7aa8dd07f635e8b
treefd1bc4f2ef434f4ae2c55c355e8a06015f957191
parentf31a308c44bd155fd842f3b14d4a5e678fcf06d9
usb: ucsi: Fix NULL pointer deref in ucsi_connector_change()

BugLink: https://bugs.launchpad.net/bugs/2016877
commit f87fb985452ab2083967103ac00bfd68fb182764 upstream.

When ucsi_init() fails, ucsi->connector is NULL, yet in case of
ucsi_acpi we may still get events which cause the ucs_acpi code to call
ucsi_connector_change(), which then derefs the NULL ucsi->connector
pointer.

Fix this by not setting ucsi->ntfy inside ucsi_init() until ucsi_init()
has succeeded, so that ucsi_connector_change() ignores the events
because UCSI_ENABLE_NTFY_CONNECTOR_CHANGE is not set in the ntfy mask.

Fixes: bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=217106
Cc: stable@vger.kernel.org
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230308154244.722337-2-hdegoede@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/usb/typec/ucsi/ucsi.c