lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230804084928.1153600-1-hhhuuu@google.com>
Date:   Fri,  4 Aug 2023 08:49:28 +0000
From:   Jimmy Hu <hhhuuu@...gle.com>
To:     linux@...ck-us.net, heikki.krogerus@...ux.intel.com,
        gregkh@...uxfoundation.org
Cc:     kyletso@...gle.com, badhri@...gle.com, linux-usb@...r.kernel.org,
        linux-kernel@...r.kernel.org, Jimmy Hu <hhhuuu@...gle.com>
Subject: [PATCH v2] usb: typec: tcpm: IS_ERR_OR_NULL check for port->partner

port->partner may be an error or NULL, so we must check it with
IS_ERR_OR_NULL() before dereferencing it.

Move the check to the beginning of the tcpm_handle_vdm_request function.

Fixes: 5e1d4c49fbc8 ("usb: typec: tcpm: Determine common SVDM Version")
Signed-off-by: Jimmy Hu <hhhuuu@...gle.com>
---
 drivers/usb/typec/tcpm/tcpm.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 829d75ebab42..2c6a0af155ab 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -1683,10 +1683,6 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev,
 			      (VDO_SVDM_VERS(typec_get_negotiated_svdm_version(typec)));
 		break;
 	case CMDT_RSP_ACK:
-		/* silently drop message if we are not connected */
-		if (IS_ERR_OR_NULL(port->partner))
-			break;
-
 		tcpm_ams_finish(port);
 
 		switch (cmd) {
@@ -1792,6 +1788,12 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port,
 	u32 response[8] = { };
 	int i, rlen = 0;
 
+	/* silently drop message if we are not connected */
+	if (IS_ERR_OR_NULL(port->partner)) {
+		dev_warn(port->dev, "port partner is an error or NULL\n");
+		return;
+	}
+
 	for (i = 0; i < cnt; i++)
 		p[i] = le32_to_cpu(payload[i]);
 
-- 
2.41.0.585.gd2178a4bd4-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ