mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: typec: tcpm: Add IS_ERR_OR_NULL check for port->partner
@ 2023-06-30  6:57 Jimmy Hu
  2023-07-31 11:06 ` Heikki Krogerus
  0 siblings, 1 reply; 3+ messages in thread
From: Jimmy Hu @ 2023-06-30  6:57 UTC (permalink / raw)
  To: linux, heikki.krogerus, gregkh; +Cc: kyletso, linux-usb, linux-kernel, Jimmy Hu

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

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

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 829d75ebab42..cd2590eead04 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -1626,6 +1626,8 @@ static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev,
 				break;
 
 			if (PD_VDO_SVDM_VER(p[0]) < svdm_version) {
+				if (IS_ERR_OR_NULL(port->partner))
+					break;
 				typec_partner_set_svdm_version(port->partner,
 							       PD_VDO_SVDM_VER(p[0]));
 				svdm_version = PD_VDO_SVDM_VER(p[0]);
-- 
2.41.0.255.g8b1d071c50-goog


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

end of thread, other threads:[~2023-08-01  3:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-30  6:57 [PATCH] usb: typec: tcpm: Add IS_ERR_OR_NULL check for port->partner Jimmy Hu
2023-07-31 11:06 ` Heikki Krogerus
2023-08-01  3:21   ` Jimmy Hu

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

all inboxes | Powered by JetHome®