Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: typec: ucsi: Fix 2 unlocked ucsi_run_command calls

Fix 2 unlocked ucsi_run_command calls:

1. ucsi_handle_connector_change() contains one ucsi_send_command() call,
which takes the ppm_lock for it; and one ucsi_run_command() call which
relies on the caller have taking the ppm_lock.
ucsi_handle_connector_change() does not take the lock, so the
second (ucsi_run_command) calls should also be ucsi_send_command().

2. ucsi_get_pdos() gets called from ucsi_handle_connector_change() which
does not hold the ppm_lock, so it also must use ucsi_send_command().

This commit also adds a WARN_ON(!mutex_is_locked(&ucsi->ppm_lock)); to
ucsi_run_command() to avoid similar problems getting re-introduced in
the future.

Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20200809141904.4317-3-hdegoede@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Hans de Goede and committed by
Greg Kroah-Hartman
7e90057f 0ff0705a

+4 -2
+4 -2
drivers/usb/typec/ucsi/ucsi.c
··· 152 152 u8 length; 153 153 int ret; 154 154 155 + WARN_ON(!mutex_is_locked(&ucsi->ppm_lock)); 156 + 155 157 ret = ucsi_exec_command(ucsi, command); 156 158 if (ret < 0) 157 159 return ret; ··· 504 502 command |= UCSI_GET_PDOS_PARTNER_PDO(is_partner); 505 503 command |= UCSI_GET_PDOS_NUM_PDOS(UCSI_MAX_PDOS - 1); 506 504 command |= UCSI_GET_PDOS_SRC_PDOS; 507 - ret = ucsi_run_command(ucsi, command, con->src_pdos, 505 + ret = ucsi_send_command(ucsi, command, con->src_pdos, 508 506 sizeof(con->src_pdos)); 509 507 if (ret < 0) { 510 508 dev_err(ucsi->dev, "UCSI_GET_PDOS failed (%d)\n", ret); ··· 683 681 */ 684 682 command = UCSI_GET_CAM_SUPPORTED; 685 683 command |= UCSI_CONNECTOR_NUMBER(con->num); 686 - ucsi_run_command(con->ucsi, command, NULL, 0); 684 + ucsi_send_command(con->ucsi, command, NULL, 0); 687 685 } 688 686 689 687 if (con->status.change & UCSI_CONSTAT_PARTNER_CHANGE)