From da1f1493c8807972d79c6673f228e562719b2ed4 Mon Sep 17 00:00:00 2001 From: Pratham Pratap Date: Wed, 18 Aug 2021 13:57:34 +0530 Subject: [PATCH] usb: pd: Clear vdm_tx if SVDM message is sent on SOP' Consider a case where SVDM message sent on SOP' failed before starting the power negotiation with the sink. Currently pd driver will not be freeing vdm_tx and will be kept around till we reach PE_SRC_Ready state. Now the same will be sent on SOP instead of SOP' and also with wrong SVDM version which was kept for the first SVDM msg, because of Commit I0bafb619e0a("usb: pd: Correctly handle SVDM versions), causing the other partner to NAK it. Fix this by clearing the vdm_tx if SVDM message is sent on SOP'(intended of e-mark cable) which has been failed. Change-Id: I729a66058ea8829625185483cbec87b435ee66fc Signed-off-by: Pratham Pratap --- drivers/usb/pd/policy_engine.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/pd/policy_engine.c b/drivers/usb/pd/policy_engine.c index b3d799dfab5b..9f6bd3b811bd 100644 --- a/drivers/usb/pd/policy_engine.c +++ b/drivers/usb/pd/policy_engine.c @@ -1721,8 +1721,12 @@ static void handle_vdm_tx(struct usbpd *pd, enum pd_sop_type sop_type) mutex_unlock(&pd->svid_handler_lock); /* retry when hitting PE_SRC/SNK_Ready again */ - if (ret != -EBUSY && sop_type == SOP_MSG) + if (ret != -EBUSY && sop_type == SOP_MSG) { usbpd_set_state(pd, PE_SEND_SOFT_RESET); + } else if (sop_type != SOP_MSG) { + kfree(pd->vdm_tx); + pd->vdm_tx = NULL; + } return; }