Skip to content

Commit 754498c

Browse files
jwrdegoedegregkh
authored andcommitted
usb: typec: tcpm: Add WARN_ON ensure we are not trying to send 2 VDM packets at the same time
The tcpm.c code for sending VDMs assumes that there will only be one VDM in flight at the time. The "queue" used by tcpm_queue_vdm is only 1 entry deep. This assumes that the higher layers (tcpm state-machine and alt-mode drivers) ensure that queuing a new VDM before the old one has been completely send (or it timed out) add a WARN_ON to check for this. Reviewed-by: Heikki Krogerus <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a37241d commit 754498c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/usb/typec/tcpm/tcpm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,9 @@ static void tcpm_queue_vdm(struct tcpm_port *port, const u32 header,
971971
{
972972
WARN_ON(!mutex_is_locked(&port->lock));
973973

974+
/* Make sure we are not still processing a previous VDM packet */
975+
WARN_ON(port->vdm_state > VDM_STATE_DONE);
976+
974977
port->vdo_count = cnt + 1;
975978
port->vdo_data[0] = header;
976979
memcpy(&port->vdo_data[1], data, sizeof(u32) * cnt);

0 commit comments

Comments
 (0)