public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: typec: qcom-pmic: fix uninitialized value hdr_len and txbuf_len
@ 2024-10-29  2:18 Rex Nie
  2024-10-29  2:30 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Rex Nie @ 2024-10-29  2:18 UTC (permalink / raw)
  To: bryan.odonoghue, heikki.krogerus
  Cc: gregkh, linux-arm-msm, linux-usb, linux-kernel, angus.chen,
	Rex Nie

If the read of USB_PDPHY_RX_ACKNOWLEDGE_REG failed, then hdr_len and
txbuf_len are uninitialized. It makes no sense to print message header
and payload. It is also not safe to print uninitialized length of ram.

Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>
---
 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
index 5b7f52b74a40..53c2180a773a 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
@@ -221,7 +221,7 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
 					  unsigned int negotiated_rev)
 {
 	struct device *dev = pmic_typec_pdphy->dev;
-	unsigned int val, hdr_len, txbuf_len, txsize_len;
+	unsigned int val, hdr_len = 0, txbuf_len = 0, txsize_len;
 	unsigned long flags;
 	int ret;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] usb: typec: qcom-pmic: fix uninitialized value hdr_len and txbuf_len
  2024-10-29  2:18 [PATCH] usb: typec: qcom-pmic: fix uninitialized value hdr_len and txbuf_len Rex Nie
@ 2024-10-29  2:30 ` Greg KH
  2024-10-29  6:28   ` 答复: " Rex Nie
  2024-10-29 15:28 ` Bjorn Andersson
  2024-10-30  2:27 ` [PATCH v2] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier Rex Nie
  2 siblings, 1 reply; 16+ messages in thread
From: Greg KH @ 2024-10-29  2:30 UTC (permalink / raw)
  To: Rex Nie
  Cc: bryan.odonoghue, heikki.krogerus, linux-arm-msm, linux-usb,
	linux-kernel, angus.chen

On Tue, Oct 29, 2024 at 10:18:23AM +0800, Rex Nie wrote:
> If the read of USB_PDPHY_RX_ACKNOWLEDGE_REG failed, then hdr_len and
> txbuf_len are uninitialized. It makes no sense to print message header
> and payload. It is also not safe to print uninitialized length of ram.
> 
> Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>

What commit id does this fix?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 16+ messages in thread

* 答复: [PATCH] usb: typec: qcom-pmic: fix uninitialized value hdr_len and txbuf_len
  2024-10-29  2:30 ` Greg KH
@ 2024-10-29  6:28   ` Rex Nie
  0 siblings, 0 replies; 16+ messages in thread
From: Rex Nie @ 2024-10-29  6:28 UTC (permalink / raw)
  To: Greg KH
  Cc: bryan.odonoghue@linaro.org, heikki.krogerus@linux.intel.com,
	linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, Angus Chen


> -----邮件原件-----
> 发件人: Greg KH <gregkh@linuxfoundation.org>
> 发送时间: 2024年10月29日 10:31
> 收件人: Rex Nie <rex.nie@jaguarmicro.com>
> 抄送: bryan.odonoghue@linaro.org; heikki.krogerus@linux.intel.com;
> linux-arm-msm@vger.kernel.org; linux-usb@vger.kernel.org;
> linux-kernel@vger.kernel.org; Angus Chen <angus.chen@jaguarmicro.com>
> 主题: Re: [PATCH] usb: typec: qcom-pmic: fix uninitialized value hdr_len and
> txbuf_len
> 
> External Mail: This email originated from OUTSIDE of the organization!
> Do not click links, open attachments or provide ANY information unless you
> recognize the sender and know the content is safe.
> 
> 
> On Tue, Oct 29, 2024 at 10:18:23AM +0800, Rex Nie wrote:
> > If the read of USB_PDPHY_RX_ACKNOWLEDGE_REG failed, then hdr_len and
> > txbuf_len are uninitialized. It makes no sense to print message header
> > and payload. It is also not safe to print uninitialized length of ram.
> >
> > Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>
> 
> What commit id does this fix?
HI greg k-h, This patch fix the commit id: a4422ff221429c600c3dc5d0394fb3738b89d040, authored by Bryan O'Donoghue <bryan.odonoghue@linaro.org>.
Thanks
Rex
> 
> thanks,
> 
> greg k-h

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] usb: typec: qcom-pmic: fix uninitialized value hdr_len and txbuf_len
  2024-10-29  2:18 [PATCH] usb: typec: qcom-pmic: fix uninitialized value hdr_len and txbuf_len Rex Nie
  2024-10-29  2:30 ` Greg KH
@ 2024-10-29 15:28 ` Bjorn Andersson
  2024-10-29 15:38   ` Bryan O'Donoghue
  2024-10-30  2:27 ` [PATCH v2] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier Rex Nie
  2 siblings, 1 reply; 16+ messages in thread
From: Bjorn Andersson @ 2024-10-29 15:28 UTC (permalink / raw)
  To: Rex Nie
  Cc: bryan.odonoghue, heikki.krogerus, gregkh, linux-arm-msm,
	linux-usb, linux-kernel, angus.chen

On Tue, Oct 29, 2024 at 10:18:23AM GMT, Rex Nie wrote:
> If the read of USB_PDPHY_RX_ACKNOWLEDGE_REG failed, then hdr_len and
> txbuf_len are uninitialized. It makes no sense to print message header
> and payload. It is also not safe to print uninitialized length of ram.
> 
> Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>
> ---
>  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> index 5b7f52b74a40..53c2180a773a 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> @@ -221,7 +221,7 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
>  					  unsigned int negotiated_rev)
>  {
>  	struct device *dev = pmic_typec_pdphy->dev;
> -	unsigned int val, hdr_len, txbuf_len, txsize_len;
> +	unsigned int val, hdr_len = 0, txbuf_len = 0, txsize_len;

This stops us from printing uninitialized values, but the error print is
now containing misleading/false data instead.

As far as I can tell, the assignment of these three variables depend
only on the  "msg" argument passed to the function, not on the
operations leading up to their assignment.

So how about just moving the 3 assignments up to the top of the function
instead?

Regards,
Bjorn

>  	unsigned long flags;
>  	int ret;
>  
> -- 
> 2.17.1
> 
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] usb: typec: qcom-pmic: fix uninitialized value hdr_len and txbuf_len
  2024-10-29 15:28 ` Bjorn Andersson
@ 2024-10-29 15:38   ` Bryan O'Donoghue
  0 siblings, 0 replies; 16+ messages in thread
From: Bryan O'Donoghue @ 2024-10-29 15:38 UTC (permalink / raw)
  To: Bjorn Andersson, Rex Nie
  Cc: heikki.krogerus, gregkh, linux-arm-msm, linux-usb, linux-kernel,
	angus.chen

On 29/10/2024 15:28, Bjorn Andersson wrote:
>> +	unsigned int val, hdr_len = 0, txbuf_len = 0, txsize_len;
> This stops us from printing uninitialized values, but the error print is
> now containing misleading/false data instead.

Yes, the point of the error printout is to also give an indication of 
what data didn't transmit

         hdr_len = sizeof(msg->header);
         txbuf_len = pd_header_cnt_le(msg->header) * 4;

The default values of the header should probably just be latched @ the 
top of this routine.

We assume *msg contains valid data so instead of init to zero we should 
init as above.

Please do that for your V2 including

Fixes: a4422ff22142 (" usb: typec: qcom: Add Qualcomm PMIC Type-C driver")

---
bod

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier
  2024-10-29  2:18 [PATCH] usb: typec: qcom-pmic: fix uninitialized value hdr_len and txbuf_len Rex Nie
  2024-10-29  2:30 ` Greg KH
  2024-10-29 15:28 ` Bjorn Andersson
@ 2024-10-30  2:27 ` Rex Nie
  2024-10-30  8:39   ` Heikki Krogerus
                     ` (2 more replies)
  2 siblings, 3 replies; 16+ messages in thread
From: Rex Nie @ 2024-10-30  2:27 UTC (permalink / raw)
  To: bryan.odonoghue, heikki.krogerus
  Cc: gregkh, linux-arm-msm, linux-usb, linux-kernel, angus.chen,
	Rex Nie

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.

Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>
---
 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
index 5b7f52b74a40..726423684bae 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
@@ -227,6 +227,10 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
 
 	spin_lock_irqsave(&pmic_typec_pdphy->lock, flags);
 
+	hdr_len = sizeof(msg->header);
+	txbuf_len = pd_header_cnt_le(msg->header) * 4;
+	txsize_len = hdr_len + txbuf_len - 1;
+
 	ret = regmap_read(pmic_typec_pdphy->regmap,
 			  pmic_typec_pdphy->base + USB_PDPHY_RX_ACKNOWLEDGE_REG,
 			  &val);
@@ -244,10 +248,6 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
 	if (ret)
 		goto done;
 
-	hdr_len = sizeof(msg->header);
-	txbuf_len = pd_header_cnt_le(msg->header) * 4;
-	txsize_len = hdr_len + txbuf_len - 1;
-
 	/* Write message header sizeof(u16) to USB_PDPHY_TX_BUFFER_HDR_REG */
 	ret = regmap_bulk_write(pmic_typec_pdphy->regmap,
 				pmic_typec_pdphy->base + USB_PDPHY_TX_BUFFER_HDR_REG,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier
  2024-10-30  2:27 ` [PATCH v2] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier Rex Nie
@ 2024-10-30  8:39   ` Heikki Krogerus
  2024-10-30 10:35     ` 答复: " Rex Nie
  2024-10-30 10:32   ` [PATCH v3] " Rex Nie
  2024-10-30 13:36   ` [PATCH v4] " Rex Nie
  2 siblings, 1 reply; 16+ messages in thread
From: Heikki Krogerus @ 2024-10-30  8:39 UTC (permalink / raw)
  To: Rex Nie
  Cc: bryan.odonoghue, gregkh, linux-arm-msm, linux-usb, linux-kernel,
	angus.chen

Hi,

On Wed, Oct 30, 2024 at 10:27:54AM +0800, Rex Nie wrote:
> 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.
> 
> Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>
> ---

You need to include a changelog also for the patch itself here, after
that "---" separator. This patch is also still missing the Fixes tag.

You can read more about how to send the patches from the documentation:
https://www.kernel.org/doc/html/latest/process/submitting-patches.html

So please send v3 with those fixed. Don't forget to Cc the stable ml.:
https://www.kernel.org/doc/html/latest/process/submitting-patches.html#select-the-recipients-for-your-patch

thanks,

>  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> index 5b7f52b74a40..726423684bae 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> @@ -227,6 +227,10 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
>  
>  	spin_lock_irqsave(&pmic_typec_pdphy->lock, flags);
>  
> +	hdr_len = sizeof(msg->header);
> +	txbuf_len = pd_header_cnt_le(msg->header) * 4;
> +	txsize_len = hdr_len + txbuf_len - 1;
> +
>  	ret = regmap_read(pmic_typec_pdphy->regmap,
>  			  pmic_typec_pdphy->base + USB_PDPHY_RX_ACKNOWLEDGE_REG,
>  			  &val);
> @@ -244,10 +248,6 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
>  	if (ret)
>  		goto done;
>  
> -	hdr_len = sizeof(msg->header);
> -	txbuf_len = pd_header_cnt_le(msg->header) * 4;
> -	txsize_len = hdr_len + txbuf_len - 1;
> -
>  	/* Write message header sizeof(u16) to USB_PDPHY_TX_BUFFER_HDR_REG */
>  	ret = regmap_bulk_write(pmic_typec_pdphy->regmap,
>  				pmic_typec_pdphy->base + USB_PDPHY_TX_BUFFER_HDR_REG,
> -- 
> 2.17.1

-- 
heikki

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v3] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier
  2024-10-30  2:27 ` [PATCH v2] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier Rex Nie
  2024-10-30  8:39   ` Heikki Krogerus
@ 2024-10-30 10:32   ` Rex Nie
  2024-10-30 12:31     ` Bryan O'Donoghue
  2024-10-30 13:19     ` Heikki Krogerus
  2024-10-30 13:36   ` [PATCH v4] " Rex Nie
  2 siblings, 2 replies; 16+ messages in thread
From: Rex Nie @ 2024-10-30 10:32 UTC (permalink / raw)
  To: bryan.odonoghue, heikki.krogerus
  Cc: gregkh, linux, caleb.connolly, linux-arm-msm, linux-usb,
	linux-kernel, angus.chen, stable, Rex Nie

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.

---
V2 -> V3:
- add changelog, add Fixes tag, add Cc stable ml. Thanks heikki
- Link to v2: https://lore.kernel.org/all/20241030022753.2045-1-rex.nie@jaguarmicro.com/
V1 -> V2:
- keep printout when data didn't transmit, thanks Bjorn, bod, greg k-h
- Links: https://lore.kernel.org/all/b177e736-e640-47ed-9f1e-ee65971dfc9c@linaro.org/

Cc: stable@vger.kernel.org
Fixes: a4422ff22142 (" usb: typec: qcom: Add Qualcomm PMIC Type-C driver")
Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>
---
 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
index 5b7f52b74a40..726423684bae 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
@@ -227,6 +227,10 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
 
 	spin_lock_irqsave(&pmic_typec_pdphy->lock, flags);
 
+	hdr_len = sizeof(msg->header);
+	txbuf_len = pd_header_cnt_le(msg->header) * 4;
+	txsize_len = hdr_len + txbuf_len - 1;
+
 	ret = regmap_read(pmic_typec_pdphy->regmap,
 			  pmic_typec_pdphy->base + USB_PDPHY_RX_ACKNOWLEDGE_REG,
 			  &val);
@@ -244,10 +248,6 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
 	if (ret)
 		goto done;
 
-	hdr_len = sizeof(msg->header);
-	txbuf_len = pd_header_cnt_le(msg->header) * 4;
-	txsize_len = hdr_len + txbuf_len - 1;
-
 	/* Write message header sizeof(u16) to USB_PDPHY_TX_BUFFER_HDR_REG */
 	ret = regmap_bulk_write(pmic_typec_pdphy->regmap,
 				pmic_typec_pdphy->base + USB_PDPHY_TX_BUFFER_HDR_REG,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* 答复: [PATCH v2] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier
  2024-10-30  8:39   ` Heikki Krogerus
@ 2024-10-30 10:35     ` Rex Nie
  0 siblings, 0 replies; 16+ messages in thread
From: Rex Nie @ 2024-10-30 10:35 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: bryan.odonoghue@linaro.org, gregkh@linuxfoundation.org,
	linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, Angus Chen

HI heikki,
	Thanks. I will send patch v3 soon.
BRs
Rex

> -----邮件原件-----
> 发件人: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> 发送时间: 2024年10月30日 16:39
> 收件人: Rex Nie <rex.nie@jaguarmicro.com>
> 抄送: bryan.odonoghue@linaro.org; gregkh@linuxfoundation.org;
> linux-arm-msm@vger.kernel.org; linux-usb@vger.kernel.org;
> linux-kernel@vger.kernel.org; Angus Chen <angus.chen@jaguarmicro.com>
> 主题: Re: [PATCH v2] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len
> earlier
> 
> External Mail: This email originated from OUTSIDE of the organization!
> Do not click links, open attachments or provide ANY information unless you
> recognize the sender and know the content is safe.
> 
> 
> Hi,
> 
> On Wed, Oct 30, 2024 at 10:27:54AM +0800, Rex Nie wrote:
> > 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.
> >
> > Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>
> > ---
> 
> You need to include a changelog also for the patch itself here, after that "---"
> separator. This patch is also still missing the Fixes tag.
> 
> You can read more about how to send the patches from the documentation:
> https://www.kernel.org/doc/html/latest/process/submitting-patches.html
> 
> So please send v3 with those fixed. Don't forget to Cc the stable ml.:
> https://www.kernel.org/doc/html/latest/process/submitting-patches.html#s
> elect-the-recipients-for-your-patch
> 
> thanks,
> 
> >  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> > b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> > index 5b7f52b74a40..726423684bae 100644
> > --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> > +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> > @@ -227,6 +227,10 @@
> qcom_pmic_typec_pdphy_pd_transmit_payload(struct
> > pmic_typec_pdphy *pmic_typec_pd
> >
> >       spin_lock_irqsave(&pmic_typec_pdphy->lock, flags);
> >
> > +     hdr_len = sizeof(msg->header);
> > +     txbuf_len = pd_header_cnt_le(msg->header) * 4;
> > +     txsize_len = hdr_len + txbuf_len - 1;
> > +
> >       ret = regmap_read(pmic_typec_pdphy->regmap,
> >                         pmic_typec_pdphy->base +
> USB_PDPHY_RX_ACKNOWLEDGE_REG,
> >                         &val);
> > @@ -244,10 +248,6 @@
> qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy
> *pmic_typec_pd
> >       if (ret)
> >               goto done;
> >
> > -     hdr_len = sizeof(msg->header);
> > -     txbuf_len = pd_header_cnt_le(msg->header) * 4;
> > -     txsize_len = hdr_len + txbuf_len - 1;
> > -
> >       /* Write message header sizeof(u16) to
> USB_PDPHY_TX_BUFFER_HDR_REG */
> >       ret = regmap_bulk_write(pmic_typec_pdphy->regmap,
> >                               pmic_typec_pdphy->base +
> > USB_PDPHY_TX_BUFFER_HDR_REG,
> > --
> > 2.17.1
> 
> --
> heikki

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier
  2024-10-30 10:32   ` [PATCH v3] " Rex Nie
@ 2024-10-30 12:31     ` Bryan O'Donoghue
  2024-10-30 13:19     ` Heikki Krogerus
  1 sibling, 0 replies; 16+ messages in thread
From: Bryan O'Donoghue @ 2024-10-30 12:31 UTC (permalink / raw)
  To: Rex Nie, heikki.krogerus
  Cc: gregkh, linux, caleb.connolly, linux-arm-msm, linux-usb,
	linux-kernel, angus.chen, stable

On 30/10/2024 10:32, Rex Nie wrote:
> 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.
> 
> ---
> V2 -> V3:
> - add changelog, add Fixes tag, add Cc stable ml. Thanks heikki
> - Link to v2: https://lore.kernel.org/all/20241030022753.2045-1-rex.nie@jaguarmicro.com/
> V1 -> V2:
> - keep printout when data didn't transmit, thanks Bjorn, bod, greg k-h
> - Links: https://lore.kernel.org/all/b177e736-e640-47ed-9f1e-ee65971dfc9c@linaro.org/
> 
> Cc: stable@vger.kernel.org
> Fixes: a4422ff22142 (" usb: typec: qcom: Add Qualcomm PMIC Type-C driver")
> Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>
> ---
>   drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> index 5b7f52b74a40..726423684bae 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> @@ -227,6 +227,10 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
>   
>   	spin_lock_irqsave(&pmic_typec_pdphy->lock, flags);
>   
> +	hdr_len = sizeof(msg->header);
> +	txbuf_len = pd_header_cnt_le(msg->header) * 4;
> +	txsize_len = hdr_len + txbuf_len - 1;
> +
>   	ret = regmap_read(pmic_typec_pdphy->regmap,
>   			  pmic_typec_pdphy->base + USB_PDPHY_RX_ACKNOWLEDGE_REG,
>   			  &val);
> @@ -244,10 +248,6 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
>   	if (ret)
>   		goto done;
>   
> -	hdr_len = sizeof(msg->header);
> -	txbuf_len = pd_header_cnt_le(msg->header) * 4;
> -	txsize_len = hdr_len + txbuf_len - 1;
> -
>   	/* Write message header sizeof(u16) to USB_PDPHY_TX_BUFFER_HDR_REG */
>   	ret = regmap_bulk_write(pmic_typec_pdphy->regmap,
>   				pmic_typec_pdphy->base + USB_PDPHY_TX_BUFFER_HDR_REG,
Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier
  2024-10-30 10:32   ` [PATCH v3] " Rex Nie
  2024-10-30 12:31     ` Bryan O'Donoghue
@ 2024-10-30 13:19     ` Heikki Krogerus
  2024-10-30 13:37       ` 答复: " Rex Nie
  1 sibling, 1 reply; 16+ messages in thread
From: Heikki Krogerus @ 2024-10-30 13:19 UTC (permalink / raw)
  To: Rex Nie
  Cc: bryan.odonoghue, gregkh, linux, caleb.connolly, linux-arm-msm,
	linux-usb, linux-kernel, angus.chen, stable

On Wed, Oct 30, 2024 at 06:32:57PM +0800, Rex Nie wrote:
> 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.
> 
> ---
> V2 -> V3:
> - add changelog, add Fixes tag, add Cc stable ml. Thanks heikki
> - Link to v2: https://lore.kernel.org/all/20241030022753.2045-1-rex.nie@jaguarmicro.com/
> V1 -> V2:
> - keep printout when data didn't transmit, thanks Bjorn, bod, greg k-h
> - Links: https://lore.kernel.org/all/b177e736-e640-47ed-9f1e-ee65971dfc9c@linaro.org/
> 
> Cc: stable@vger.kernel.org
> Fixes: a4422ff22142 (" usb: typec: qcom: Add Qualcomm PMIC Type-C driver")
> Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>

Sorry, but this is still broken.

Those tags need to come before the "---". Otherwise they will not
end-up into the actual commit when this patch is applied.

It should look something like this:

        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: stable@vger.kernel.org
        Fixes: a4422ff22142 (" usb: typec: qcom: Add Qualcomm PMIC Type-C driver")
        Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>
        ---
        V2 -> V3:
        - add changelog, add Fixes tag, add Cc stable ml. Thanks heikki
        - Link to v2: https://lore.kernel.org/all/20241030022753.2045-1-rex.nie@jaguarmicro.com/
        V1 -> V2:
        - keep printout when data didn't transmit, thanks Bjorn, bod, greg k-h
        - Links: https://lore.kernel.org/all/b177e736-e640-47ed-9f1e-ee65971dfc9c@linaro.org/

         drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 8 ++++----
         1 file changed, 4 insertions(+), 4 deletions(-)

        diff --git a/drivers/usb/typec...

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v4] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier
  2024-10-30  2:27 ` [PATCH v2] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier Rex Nie
  2024-10-30  8:39   ` Heikki Krogerus
  2024-10-30 10:32   ` [PATCH v3] " Rex Nie
@ 2024-10-30 13:36   ` Rex Nie
  2024-10-31 10:56     ` Heikki Krogerus
  2024-11-01 15:45     ` Bjorn Andersson
  2 siblings, 2 replies; 16+ messages in thread
From: Rex Nie @ 2024-10-30 13:36 UTC (permalink / raw)
  To: bryan.odonoghue, heikki.krogerus
  Cc: gregkh, linux, caleb.connolly, linux-arm-msm, linux-usb,
	linux-kernel, angus.chen, stable, Rex Nie

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: stable@vger.kernel.org
Fixes: a4422ff22142 (" usb: typec: qcom: Add Qualcomm PMIC Type-C driver")
Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>
---
V2 -> V3:
- add changelog, add Fixes tag, add Cc stable ml. Thanks heikki
- Link to v2: https://lore.kernel.org/all/20241030022753.2045-1-rex.nie@jaguarmicro.com/
V1 -> V2:
- keep printout when data didn't transmit, thanks Bjorn, bod, greg k-h
- Links: https://lore.kernel.org/all/b177e736-e640-47ed-9f1e-ee65971dfc9c@linaro.org/
---
 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
index 5b7f52b74a40..726423684bae 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
@@ -227,6 +227,10 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
 
 	spin_lock_irqsave(&pmic_typec_pdphy->lock, flags);
 
+	hdr_len = sizeof(msg->header);
+	txbuf_len = pd_header_cnt_le(msg->header) * 4;
+	txsize_len = hdr_len + txbuf_len - 1;
+
 	ret = regmap_read(pmic_typec_pdphy->regmap,
 			  pmic_typec_pdphy->base + USB_PDPHY_RX_ACKNOWLEDGE_REG,
 			  &val);
@@ -244,10 +248,6 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
 	if (ret)
 		goto done;
 
-	hdr_len = sizeof(msg->header);
-	txbuf_len = pd_header_cnt_le(msg->header) * 4;
-	txsize_len = hdr_len + txbuf_len - 1;
-
 	/* Write message header sizeof(u16) to USB_PDPHY_TX_BUFFER_HDR_REG */
 	ret = regmap_bulk_write(pmic_typec_pdphy->regmap,
 				pmic_typec_pdphy->base + USB_PDPHY_TX_BUFFER_HDR_REG,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* 答复: [PATCH v3] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier
  2024-10-30 13:19     ` Heikki Krogerus
@ 2024-10-30 13:37       ` Rex Nie
  0 siblings, 0 replies; 16+ messages in thread
From: Rex Nie @ 2024-10-30 13:37 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: bryan.odonoghue@linaro.org, gregkh@linuxfoundation.org,
	linux@roeck-us.net, caleb.connolly@linaro.org,
	linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, Angus Chen, stable@vger.kernel.org

Thanks again, heikki.

> -----邮件原件-----
> 发件人: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> 发送时间: 2024年10月30日 21:20
> 收件人: Rex Nie <rex.nie@jaguarmicro.com>
> 抄送: bryan.odonoghue@linaro.org; gregkh@linuxfoundation.org;
> linux@roeck-us.net; caleb.connolly@linaro.org;
> linux-arm-msm@vger.kernel.org; linux-usb@vger.kernel.org;
> linux-kernel@vger.kernel.org; Angus Chen <angus.chen@jaguarmicro.com>;
> stable@vger.kernel.org
> 主题: Re: [PATCH v3] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len
> earlier
> 
> External Mail: This email originated from OUTSIDE of the organization!
> Do not click links, open attachments or provide ANY information unless you
> recognize the sender and know the content is safe.
> 
> 
> On Wed, Oct 30, 2024 at 06:32:57PM +0800, Rex Nie wrote:
> > 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.
> >
> > ---
> > V2 -> V3:
> > - add changelog, add Fixes tag, add Cc stable ml. Thanks heikki
> > - Link to v2:
> > https://lore.kernel.org/all/20241030022753.2045-1-rex.nie@jaguarmicro.
> > com/
> > V1 -> V2:
> > - keep printout when data didn't transmit, thanks Bjorn, bod, greg k-h
> > - Links:
> > https://lore.kernel.org/all/b177e736-e640-47ed-9f1e-ee65971dfc9c@linar
> > o.org/
> >
> > Cc: stable@vger.kernel.org
> > Fixes: a4422ff22142 (" usb: typec: qcom: Add Qualcomm PMIC Type-C
> > driver")
> > Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>
> 
> Sorry, but this is still broken.
> 
> Those tags need to come before the "---". Otherwise they will not end-up into
> the actual commit when this patch is applied.
> 
> It should look something like this:
> 
>         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: stable@vger.kernel.org
>         Fixes: a4422ff22142 (" usb: typec: qcom: Add Qualcomm PMIC
> Type-C driver")
>         Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>
>         ---
>         V2 -> V3:
>         - add changelog, add Fixes tag, add Cc stable ml. Thanks heikki
>         - Link to v2:
> https://lore.kernel.org/all/20241030022753.2045-1-rex.nie@jaguarmicro.co
> m/
>         V1 -> V2:
>         - keep printout when data didn't transmit, thanks Bjorn, bod, greg
> k-h
>         - Links:
> https://lore.kernel.org/all/b177e736-e640-47ed-9f1e-ee65971dfc9c@linaro.
> org/
> 
>          drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 8
> ++++----
>          1 file changed, 4 insertions(+), 4 deletions(-)
> 
>         diff --git a/drivers/usb/typec...
> 
> thanks,
> 
> --
> heikki

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier
  2024-10-30 13:36   ` [PATCH v4] " Rex Nie
@ 2024-10-31 10:56     ` Heikki Krogerus
  2024-11-01 15:45     ` Bjorn Andersson
  1 sibling, 0 replies; 16+ messages in thread
From: Heikki Krogerus @ 2024-10-31 10:56 UTC (permalink / raw)
  To: Rex Nie
  Cc: bryan.odonoghue, gregkh, linux, caleb.connolly, linux-arm-msm,
	linux-usb, linux-kernel, angus.chen, stable

On Wed, Oct 30, 2024 at 09:36:32PM +0800, Rex Nie wrote:
> 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: stable@vger.kernel.org
> Fixes: a4422ff22142 (" usb: typec: qcom: Add Qualcomm PMIC Type-C driver")
> Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
> V2 -> V3:
> - add changelog, add Fixes tag, add Cc stable ml. Thanks heikki
> - Link to v2: https://lore.kernel.org/all/20241030022753.2045-1-rex.nie@jaguarmicro.com/
> V1 -> V2:
> - keep printout when data didn't transmit, thanks Bjorn, bod, greg k-h
> - Links: https://lore.kernel.org/all/b177e736-e640-47ed-9f1e-ee65971dfc9c@linaro.org/
> ---
>  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> index 5b7f52b74a40..726423684bae 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> @@ -227,6 +227,10 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
>  
>  	spin_lock_irqsave(&pmic_typec_pdphy->lock, flags);
>  
> +	hdr_len = sizeof(msg->header);
> +	txbuf_len = pd_header_cnt_le(msg->header) * 4;
> +	txsize_len = hdr_len + txbuf_len - 1;
> +
>  	ret = regmap_read(pmic_typec_pdphy->regmap,
>  			  pmic_typec_pdphy->base + USB_PDPHY_RX_ACKNOWLEDGE_REG,
>  			  &val);
> @@ -244,10 +248,6 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
>  	if (ret)
>  		goto done;
>  
> -	hdr_len = sizeof(msg->header);
> -	txbuf_len = pd_header_cnt_le(msg->header) * 4;
> -	txsize_len = hdr_len + txbuf_len - 1;
> -
>  	/* Write message header sizeof(u16) to USB_PDPHY_TX_BUFFER_HDR_REG */
>  	ret = regmap_bulk_write(pmic_typec_pdphy->regmap,
>  				pmic_typec_pdphy->base + USB_PDPHY_TX_BUFFER_HDR_REG,
> -- 
> 2.17.1

-- 
heikki

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v4] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier
  2024-10-30 13:36   ` [PATCH v4] " Rex Nie
  2024-10-31 10:56     ` Heikki Krogerus
@ 2024-11-01 15:45     ` Bjorn Andersson
  2024-11-02 12:27       ` 答复: " Rex Nie
  1 sibling, 1 reply; 16+ messages in thread
From: Bjorn Andersson @ 2024-11-01 15:45 UTC (permalink / raw)
  To: Rex Nie
  Cc: bryan.odonoghue, heikki.krogerus, gregkh, linux, caleb.connolly,
	linux-arm-msm, linux-usb, linux-kernel, angus.chen, stable

On Wed, Oct 30, 2024 at 09:36:32PM GMT, Rex Nie wrote:
> 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: stable@vger.kernel.org
> Fixes: a4422ff22142 (" usb: typec: qcom: Add Qualcomm PMIC Type-C driver")
> Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>

Reviewed-by: Bjorn Andersson <andersson@kernel.org>

Nice job. Next time, please don't use In-Reply-To between patch
versions.

Regards,
Bjorn

> ---
> V2 -> V3:
> - add changelog, add Fixes tag, add Cc stable ml. Thanks heikki
> - Link to v2: https://lore.kernel.org/all/20241030022753.2045-1-rex.nie@jaguarmicro.com/
> V1 -> V2:
> - keep printout when data didn't transmit, thanks Bjorn, bod, greg k-h
> - Links: https://lore.kernel.org/all/b177e736-e640-47ed-9f1e-ee65971dfc9c@linaro.org/
> ---
>  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> index 5b7f52b74a40..726423684bae 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> @@ -227,6 +227,10 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
>  
>  	spin_lock_irqsave(&pmic_typec_pdphy->lock, flags);
>  
> +	hdr_len = sizeof(msg->header);
> +	txbuf_len = pd_header_cnt_le(msg->header) * 4;
> +	txsize_len = hdr_len + txbuf_len - 1;
> +
>  	ret = regmap_read(pmic_typec_pdphy->regmap,
>  			  pmic_typec_pdphy->base + USB_PDPHY_RX_ACKNOWLEDGE_REG,
>  			  &val);
> @@ -244,10 +248,6 @@ qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy *pmic_typec_pd
>  	if (ret)
>  		goto done;
>  
> -	hdr_len = sizeof(msg->header);
> -	txbuf_len = pd_header_cnt_le(msg->header) * 4;
> -	txsize_len = hdr_len + txbuf_len - 1;
> -
>  	/* Write message header sizeof(u16) to USB_PDPHY_TX_BUFFER_HDR_REG */
>  	ret = regmap_bulk_write(pmic_typec_pdphy->regmap,
>  				pmic_typec_pdphy->base + USB_PDPHY_TX_BUFFER_HDR_REG,
> -- 
> 2.17.1
> 
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* 答复: [PATCH v4] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier
  2024-11-01 15:45     ` Bjorn Andersson
@ 2024-11-02 12:27       ` Rex Nie
  0 siblings, 0 replies; 16+ messages in thread
From: Rex Nie @ 2024-11-02 12:27 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: bryan.odonoghue@linaro.org, heikki.krogerus@linux.intel.com,
	gregkh@linuxfoundation.org, linux@roeck-us.net,
	caleb.connolly@linaro.org, linux-arm-msm@vger.kernel.org,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Angus Chen, stable@vger.kernel.org

Bjorn,
	Ok, get it, Thanks.
BRs
Rex
> -----邮件原件-----
> 发件人: Bjorn Andersson <andersson@kernel.org>
> 发送时间: 2024年11月1日 23:45
> 收件人: Rex Nie <rex.nie@jaguarmicro.com>
> 抄送: bryan.odonoghue@linaro.org; heikki.krogerus@linux.intel.com;
> gregkh@linuxfoundation.org; linux@roeck-us.net; caleb.connolly@linaro.org;
> linux-arm-msm@vger.kernel.org; linux-usb@vger.kernel.org;
> linux-kernel@vger.kernel.org; Angus Chen <angus.chen@jaguarmicro.com>;
> stable@vger.kernel.org
> 主题: Re: [PATCH v4] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len
> earlier
> 
> External Mail: This email originated from OUTSIDE of the organization!
> Do not click links, open attachments or provide ANY information unless you
> recognize the sender and know the content is safe.
> 
> 
> On Wed, Oct 30, 2024 at 09:36:32PM GMT, Rex Nie wrote:
> > 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: stable@vger.kernel.org
> > Fixes: a4422ff22142 (" usb: typec: qcom: Add Qualcomm PMIC Type-C
> > driver")
> > Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>
> 
> Reviewed-by: Bjorn Andersson <andersson@kernel.org>
> 
> Nice job. Next time, please don't use In-Reply-To between patch versions.
> 
> Regards,
> Bjorn
> 
> > ---
> > V2 -> V3:
> > - add changelog, add Fixes tag, add Cc stable ml. Thanks heikki
> > - Link to v2:
> > https://lore.kernel.org/all/20241030022753.2045-1-rex.nie@jaguarmicro.
> > com/
> > V1 -> V2:
> > - keep printout when data didn't transmit, thanks Bjorn, bod, greg k-h
> > - Links:
> > https://lore.kernel.org/all/b177e736-e640-47ed-9f1e-ee65971dfc9c@linar
> > o.org/
> > ---
> >  drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> > b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> > index 5b7f52b74a40..726423684bae 100644
> > --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> > +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
> > @@ -227,6 +227,10 @@
> qcom_pmic_typec_pdphy_pd_transmit_payload(struct
> > pmic_typec_pdphy *pmic_typec_pd
> >
> >       spin_lock_irqsave(&pmic_typec_pdphy->lock, flags);
> >
> > +     hdr_len = sizeof(msg->header);
> > +     txbuf_len = pd_header_cnt_le(msg->header) * 4;
> > +     txsize_len = hdr_len + txbuf_len - 1;
> > +
> >       ret = regmap_read(pmic_typec_pdphy->regmap,
> >                         pmic_typec_pdphy->base +
> USB_PDPHY_RX_ACKNOWLEDGE_REG,
> >                         &val);
> > @@ -244,10 +248,6 @@
> qcom_pmic_typec_pdphy_pd_transmit_payload(struct pmic_typec_pdphy
> *pmic_typec_pd
> >       if (ret)
> >               goto done;
> >
> > -     hdr_len = sizeof(msg->header);
> > -     txbuf_len = pd_header_cnt_le(msg->header) * 4;
> > -     txsize_len = hdr_len + txbuf_len - 1;
> > -
> >       /* Write message header sizeof(u16) to
> USB_PDPHY_TX_BUFFER_HDR_REG */
> >       ret = regmap_bulk_write(pmic_typec_pdphy->regmap,
> >                               pmic_typec_pdphy->base +
> > USB_PDPHY_TX_BUFFER_HDR_REG,
> > --
> > 2.17.1
> >
> >

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-11-02 12:28 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-29  2:18 [PATCH] usb: typec: qcom-pmic: fix uninitialized value hdr_len and txbuf_len Rex Nie
2024-10-29  2:30 ` Greg KH
2024-10-29  6:28   ` 答复: " Rex Nie
2024-10-29 15:28 ` Bjorn Andersson
2024-10-29 15:38   ` Bryan O'Donoghue
2024-10-30  2:27 ` [PATCH v2] usb: typec: qcom-pmic: init value of hdr_len/txbuf_len earlier Rex Nie
2024-10-30  8:39   ` Heikki Krogerus
2024-10-30 10:35     ` 答复: " Rex Nie
2024-10-30 10:32   ` [PATCH v3] " Rex Nie
2024-10-30 12:31     ` Bryan O'Donoghue
2024-10-30 13:19     ` Heikki Krogerus
2024-10-30 13:37       ` 答复: " Rex Nie
2024-10-30 13:36   ` [PATCH v4] " Rex Nie
2024-10-31 10:56     ` Heikki Krogerus
2024-11-01 15:45     ` Bjorn Andersson
2024-11-02 12:27       ` 答复: " Rex Nie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox