Skip to contentSkip to conversation

usb: typec: ucsi: Only check the contract if there is a connection

PATCH In review Heikki Krogerus 3 participants 6 messages Dec 21, 2021

Subsystems (2)
lore
Share & tools
lore

Heikki Krogerus

author maintainer
#0 lore raw

PATCH v2 1/1 usb: typec: ucsi: Only check the contract if there is a connection

The driver must make sure there is an actual connection before checking details about the USB Power Delivery contract. Those details are not valid unless there is a connection.

This fixes NULL pointer dereference that is caused by an attempt to register bogus partner alternate mode that the firmware on some platform may report before the actual connection.

Fixes 6cbe4b2d5a3f ("usb: typec: ucsi: Check the partner alt modes always if there is PD contract")

---

Hi,

Instead of using the "BugLink" tag, I'm now using "Link" tag with the link to the bug as requested.

There was a request to have also another Link tag pointing to some other discussion on the mailing list, but I failed to understand what was the point with that - I also didn't find any commits where something like that had been used before.

I may be mistaken here, but I got the impression that you create the mailing list discussion just so you can have the extra Link tag pointing to it, and that Link tag you want only because you have made your scripts rely on it.

The extra email thread in any case does not seem to contain any real additional information that the bug report does not have, so the extra Link tag pointing to it does not provide any real value on top of the link to bug itself.

thanks,

--

 drivers/usb/typec/ucsi/ucsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +3 -1
index 9d6b7e02d6efb..f0c2fa19f3e0f 100644
@@ -1164,7 +1164,9 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
 		ret = 0;
 	}
 
-	if (UCSI_CONSTAT_PWR_OPMODE(con->status.flags) == UCSI_CONSTAT_PWR_OPMODE_PD) {
+	if (con->partner &&
+	    UCSI_CONSTAT_PWR_OPMODE(con->status.flags) ==
+	    UCSI_CONSTAT_PWR_OPMODE_PD) {
 		ucsi_get_src_pdos(con);
 		ucsi_check_altmodes(con);
 	}
Signature · 1 line
2.34.1
#1 lore raw
Quoted 14 lines · Heikki Krogerus

The driver must make sure there is an actual connection before checking details about the USB Power Delivery contract. Those details are not valid unless there is a connection.

This fixes NULL pointer dereference that is caused by an attempt to register bogus partner alternate mode that the firmware on some platform may report before the actual connection.

Fixes 6cbe4b2d5a3f ("usb: typec: ucsi: Check the partner alt modes always if there is PD contract")
Quoted 6 lines

---

Hi,

Instead of using the "BugLink" tag, I'm now using "Link" tag with the link to the bug as requested.

Thx!

Quoted 4 lines

There was a request to have also another Link tag pointing to some other discussion on the mailing list, but I failed to understand what was the point with that - I also didn't find any commits where something like that had been used before.

There are quite a few commits that use more that two "Link" tags, as they should point to "related discussions or any other background information behind the change" that "can be found on the web" (Quotes from Documentation/process/submitting-patches.rst) -- hence there is no

Quoted 2 lines · limit. That being

I may be mistaken here, but I got the impression that you create the mailing list discussion

You are mistaken: I created it because the bugzilla ticket was ignored in bugzilla for weeks and might have forgotten otherwise -- no wonder, was bugzilla.kernel.org is not the official place to report USB bugs according to the MAINTAINERS file.

Quoted 3 lines

just so you can have the extra Link tag
pointing to it, and that Link tag you want only because you have made your scripts rely on it.

They rely on it as almost all subsystems expect bug to be reported by mail, as they are instructed by Documentation/admin-guide/reporting-issues.rst

Quoted 4 lines

The extra email thread in any case does not seem to contain any real additional information that the bug report does not have, so the extra Link tag pointing to it does not provide any real value on top of the link to bug itself.

In this case that's true, as I have to tell regzbot about the fix then manually (the plan it to make regzbot also detect links to bugzilla.kernel.org, but I fear I have no time to work on that in the next few weeks :-/ ). But in similar cases it's different, as there the developers continued discussing the issue by mail -- then it's definitely worth linking there as well.

Thx.

Ciao, Thorsten

Quoted 19 lines

--

 drivers/usb/typec/ucsi/ucsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +3 -1
index 9d6b7e02d6efb..f0c2fa19f3e0f 100644
@@ -1164,7 +1164,9 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
 		ret = 0;
 	}
 
-	if (UCSI_CONSTAT_PWR_OPMODE(con->status.flags) == UCSI_CONSTAT_PWR_OPMODE_PD) {
+	if (con->partner &&
+	    UCSI_CONSTAT_PWR_OPMODE(con->status.flags) ==
+	    UCSI_CONSTAT_PWR_OPMODE_PD) {
 		ucsi_get_src_pdos(con);
 		ucsi_check_altmodes(con);
 	}
#2 lore raw
Quoted 56 lines · Thorsten Leemhuis
Quoted 14 lines · Heikki Krogerus

The driver must make sure there is an actual connection before checking details about the USB Power Delivery contract. Those details are not valid unless there is a connection.

This fixes NULL pointer dereference that is caused by an attempt to register bogus partner alternate mode that the firmware on some platform may report before the actual connection.

Fixes 6cbe4b2d5a3f ("usb: typec: ucsi: Check the partner alt modes always if there is PD contract")
Quoted 6 lines

---

Hi,

Instead of using the "BugLink" tag, I'm now using "Link" tag with the link to the bug as requested.

Thx!

Quoted 4 lines

There was a request to have also another Link tag pointing to some other discussion on the mailing list, but I failed to understand what was the point with that - I also didn't find any commits where something like that had been used before.

There are quite a few commits that use more that two "Link" tags, as they should point to "related discussions or any other background information behind the change" that "can be found on the web" (Quotes from Documentation/process/submitting-patches.rst) -- hence there is no

Quoted 2 lines · limit. That being

I may be mistaken here, but I got the impression that you create the mailing list discussion

You are mistaken: I created it because the bugzilla ticket was ignored in bugzilla for weeks and might have forgotten otherwise -- no wonder, was bugzilla.kernel.org is not the official place to report USB bugs according to the MAINTAINERS file.

Quoted 3 lines

just so you can have the extra Link tag
pointing to it, and that Link tag you want only because you have made your scripts rely on it.

They rely on it as almost all subsystems expect bug to be reported by mail, as they are instructed by Documentation/admin-guide/reporting-issues.rst

Quoted 4 lines

The extra email thread in any case does not seem to contain any real additional information that the bug report does not have, so the extra Link tag pointing to it does not provide any real value on top of the link to bug itself.

Quoted 6 lines

In this case that's true, as I have to tell regzbot about the fix then manually (the plan it to make regzbot also detect links to bugzilla.kernel.org, but I fear I have no time to work on that in the next few weeks :-/ ). But in similar cases it's different, as there the developers continued discussing the issue by mail -- then it's definitely worth linking there as well.

So for this case, what type of tag should I add here to get rezbot to manually pick this up?

confused,

greg k-h

#3 lore raw
Quoted 64 lines · Greg Kroah-Hartman
Quoted 56 lines · Thorsten Leemhuis
Quoted 14 lines · Heikki Krogerus

The driver must make sure there is an actual connection before checking details about the USB Power Delivery contract. Those details are not valid unless there is a connection.

This fixes NULL pointer dereference that is caused by an attempt to register bogus partner alternate mode that the firmware on some platform may report before the actual connection.

Fixes 6cbe4b2d5a3f ("usb: typec: ucsi: Check the partner alt modes always if there is PD contract")
Quoted 6 lines

---

Hi,

Instead of using the "BugLink" tag, I'm now using "Link" tag with the link to the bug as requested.

Thx!

Quoted 4 lines

There was a request to have also another Link tag pointing to some other discussion on the mailing list, but I failed to understand what was the point with that - I also didn't find any commits where something like that had been used before.

There are quite a few commits that use more that two "Link" tags, as they should point to "related discussions or any other background information behind the change" that "can be found on the web" (Quotes from Documentation/process/submitting-patches.rst) -- hence there is no

Quoted 2 lines · limit. That being

I may be mistaken here, but I got the impression that you create the mailing list discussion

You are mistaken: I created it because the bugzilla ticket was ignored in bugzilla for weeks and might have forgotten otherwise -- no wonder, was bugzilla.kernel.org is not the official place to report USB bugs according to the MAINTAINERS file.

Quoted 3 lines

just so you can have the extra Link tag
pointing to it, and that Link tag you want only because you have made your scripts rely on it.

They rely on it as almost all subsystems expect bug to be reported by mail, as they are instructed by Documentation/admin-guide/reporting-issues.rst

Quoted 4 lines

The extra email thread in any case does not seem to contain any real additional information that the bug report does not have, so the extra Link tag pointing to it does not provide any real value on top of the link to bug itself.

Quoted 6 lines

In this case that's true, as I have to tell regzbot about the fix then manually (the plan it to make regzbot also detect links to bugzilla.kernel.org, but I fear I have no time to work on that in the next few weeks :-/ ). But in similar cases it's different, as there the developers continued discussing the issue by mail -- then it's definitely worth linking there as well.

Quoted 2 lines

So for this case, what type of tag should I add here to get rezbot to manually pick this up?

Just commit it. Afterwards someone needs to send '#regzbot fixed-by:
<commit-id>' to the thread with the report, for example as a reply to this mail:
https://lore.kernel.org/linux-usb/[email protected]/

But you can leave that to me, regzbot will alert me anyway once it sees a fix with "Fixes: 6cbe4b2d5a3f". That's the commit that introduced the regression. But making regzbot mark the entry as fixed solely on this afaics would be a bad idea, as one commit can cause different regressions :-/

Making regbzot detect "Link:" tags to bugzilla tickets it knowns about is pretty high on my todo list for regzbot. I would have worked on this already, but I have to focus on other things for now to fulfil the milestones I promised to deliver with regzbot. :-/

Ciao, Thorsten

#4 lore raw
Quoted 75 lines · Thorsten Leemhuis
Quoted 64 lines · Greg Kroah-Hartman
Quoted 56 lines · Thorsten Leemhuis
Quoted 14 lines · Heikki Krogerus

The driver must make sure there is an actual connection before checking details about the USB Power Delivery contract. Those details are not valid unless there is a connection.

This fixes NULL pointer dereference that is caused by an attempt to register bogus partner alternate mode that the firmware on some platform may report before the actual connection.

Fixes 6cbe4b2d5a3f ("usb: typec: ucsi: Check the partner alt modes always if there is PD contract")
Quoted 6 lines

---

Hi,

Instead of using the "BugLink" tag, I'm now using "Link" tag with the link to the bug as requested.

Thx!

Quoted 4 lines

There was a request to have also another Link tag pointing to some other discussion on the mailing list, but I failed to understand what was the point with that - I also didn't find any commits where something like that had been used before.

There are quite a few commits that use more that two "Link" tags, as they should point to "related discussions or any other background information behind the change" that "can be found on the web" (Quotes from Documentation/process/submitting-patches.rst) -- hence there is no

Quoted 2 lines · limit. That being

I may be mistaken here, but I got the impression that you create the mailing list discussion

You are mistaken: I created it because the bugzilla ticket was ignored in bugzilla for weeks and might have forgotten otherwise -- no wonder, was bugzilla.kernel.org is not the official place to report USB bugs according to the MAINTAINERS file.

Quoted 3 lines

just so you can have the extra Link tag
pointing to it, and that Link tag you want only because you have made your scripts rely on it.

They rely on it as almost all subsystems expect bug to be reported by mail, as they are instructed by Documentation/admin-guide/reporting-issues.rst

Quoted 4 lines

The extra email thread in any case does not seem to contain any real additional information that the bug report does not have, so the extra Link tag pointing to it does not provide any real value on top of the link to bug itself.

Quoted 6 lines

In this case that's true, as I have to tell regzbot about the fix then manually (the plan it to make regzbot also detect links to bugzilla.kernel.org, but I fear I have no time to work on that in the next few weeks :-/ ). But in similar cases it's different, as there the developers continued discussing the issue by mail -- then it's definitely worth linking there as well.

Quoted 2 lines

So for this case, what type of tag should I add here to get rezbot to manually pick this up?

Just commit it. Afterwards someone needs to send '#regzbot fixed-by:
<commit-id>' to the thread with the report, for example as a reply to this mail:
https://lore.kernel.org/linux-usb/[email protected]/

Quoted 5 lines

But you can leave that to me, regzbot will alert me anyway once it sees a fix with "Fixes: 6cbe4b2d5a3f". That's the commit that introduced the regression. But making regzbot mark the entry as fixed solely on this afaics would be a bad idea, as one commit can cause different regressions :-/

Ok, thanks, now committed to my tree, hopefully gets picked up automagically...

greg k-h

author maintainer
#5 lore raw
In reply to Thorsten Leemhuis

Hi Thorsten,

Tue, Dec 21, 2021 at 03:39:04PM +0100, Thorsten Leemhuis kirjoitti:

Quoted 56 lines · Heikki Krogerus
Quoted 14 lines

The driver must make sure there is an actual connection before checking details about the USB Power Delivery contract. Those details are not valid unless there is a connection.

This fixes NULL pointer dereference that is caused by an attempt to register bogus partner alternate mode that the firmware on some platform may report before the actual connection.

Fixes 6cbe4b2d5a3f ("usb: typec: ucsi: Check the partner alt modes always if there is PD contract")
Quoted 6 lines

---

Hi,

Instead of using the "BugLink" tag, I'm now using "Link" tag with the link to the bug as requested.

Thx!

Quoted 4 lines

There was a request to have also another Link tag pointing to some other discussion on the mailing list, but I failed to understand what was the point with that - I also didn't find any commits where something like that had been used before.

There are quite a few commits that use more that two "Link" tags, as they should point to "related discussions or any other background information behind the change" that "can be found on the web" (Quotes from Documentation/process/submitting-patches.rst) -- hence there is no

Quoted 2 lines · limit. That being

I may be mistaken here, but I got the impression that you create the mailing list discussion

You are mistaken: I created it because the bugzilla ticket was ignored in bugzilla for weeks and might have forgotten otherwise -- no wonder, was bugzilla.kernel.org is not the official place to report USB bugs according to the MAINTAINERS file.

Quoted 3 lines

just so you can have the extra Link tag
pointing to it, and that Link tag you want only because you have made your scripts rely on it.

They rely on it as almost all subsystems expect bug to be reported by mail, as they are instructed by Documentation/admin-guide/reporting-issues.rst

Quoted 4 lines

The extra email thread in any case does not seem to contain any real additional information that the bug report does not have, so the extra Link tag pointing to it does not provide any real value on top of the link to bug itself.

Quoted 6 lines

In this case that's true, as I have to tell regzbot about the fix then manually (the plan it to make regzbot also detect links to bugzilla.kernel.org, but I fear I have no time to work on that in the next few weeks :-/ ). But in similar cases it's different, as there the developers continued discussing the issue by mail -- then it's definitely worth linking there as well.

Thanks for the explanation. My concern was that we are expected to supply duplicated information just so the bot is satisfied, but that's clearly not the case. I misunderstood.

thanks,

Signature · 1 line
heikki