Skip to content

Commit 029778a

Browse files
Rex Niegregkh
authored andcommitted
usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier
If the read of USB_PDPHY_RX_ACKNOWLEDGE_REG failed, then hdr_len and txbuf_len are uninitialized. This commit stops to print uninitialized value and misleading/false data. Cc: [email protected] Fixes: a4422ff (" usb: typec: qcom: Add Qualcomm PMIC Type-C driver") Signed-off-by: Rex Nie <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Acked-by: Bryan O'Donoghue <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 498dbd9 commit 029778a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
227227

228228
spin_lock_irqsave(&pmic_typec_pdphy->lock, flags);
229229

230+
hdr_len = sizeof(msg->header);
231+
txbuf_len = pd_header_cnt_le(msg->header) * 4;
232+
txsize_len = hdr_len + txbuf_len - 1;
233+
230234
ret = regmap_read(pmic_typec_pdphy->regmap,
231235
pmic_typec_pdphy->base + USB_PDPHY_RX_ACKNOWLEDGE_REG,
232236
&val);
@@ -244,10 +248,6 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
244248
if (ret)
245249
goto done;
246250

247-
hdr_len = sizeof(msg->header);
248-
txbuf_len = pd_header_cnt_le(msg->header) * 4;
249-
txsize_len = hdr_len + txbuf_len - 1;
250-
251251
/* Write message header sizeof(u16) to USB_PDPHY_TX_BUFFER_HDR_REG */
252252
ret = regmap_bulk_write(pmic_typec_pdphy->regmap,
253253
pmic_typec_pdphy->base + USB_PDPHY_TX_BUFFER_HDR_REG,

0 commit comments

Comments
 (0)