All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Thorsten Leemhuis <regressions@leemhuis.info>
Cc: linux-usb@vger.kernel.org, Chris Hixon <linux-kernel-bugs@hixontech.com>
Subject: [PATCH v2] usb: typec: ucsi: Only check the contract if there is a connection
Date: Tue, 21 Dec 2021 17:03:52 +0300	[thread overview]
Message-ID: <20211221140352.45501-1-heikki.krogerus@linux.intel.com> (raw)

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.

Reported-by: Chris Hixon <linux-kernel-bugs@hixontech.com>
Fixes: 6cbe4b2d5a3f ("usb: typec: ucsi: Check the partner alt modes always if there is PD contract")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=215117
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---

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(-)

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index 9d6b7e02d6efb..f0c2fa19f3e0f 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -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.34.1


             reply	other threads:[~2021-12-21 14:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-21 14:03 Heikki Krogerus [this message]
2021-12-21 14:39 ` [PATCH v2] usb: typec: ucsi: Only check the contract if there is a connection Thorsten Leemhuis
2021-12-21 15:03   ` Greg Kroah-Hartman
2021-12-21 15:24     ` Thorsten Leemhuis
2021-12-21 15:46       ` Greg Kroah-Hartman
2021-12-21 16:30   ` Heikki Krogerus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211221140352.45501-1-heikki.krogerus@linux.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel-bugs@hixontech.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=regressions@leemhuis.info \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.