Commit 5f54a85d authored by Heikki Krogerus's avatar Heikki Krogerus Committed by Greg Kroah-Hartman

usb: typec: Make sure an alt mode exist before getting its partner

Adding check to typec_altmode_get_partner() to prevent
potential NULL pointer dereference.
Reported-by: default avatarVladimir Yerilov <openmindead@gmail.com>
Fixes: ad74b864 ("usb: typec: ucsi: Preliminary support for alternate modes")
Signed-off-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c2ed3d47
...@@ -192,7 +192,7 @@ EXPORT_SYMBOL_GPL(typec_altmode_vdm); ...@@ -192,7 +192,7 @@ EXPORT_SYMBOL_GPL(typec_altmode_vdm);
const struct typec_altmode * const struct typec_altmode *
typec_altmode_get_partner(struct typec_altmode *adev) typec_altmode_get_partner(struct typec_altmode *adev)
{ {
return &to_altmode(adev)->partner->adev; return adev ? &to_altmode(adev)->partner->adev : NULL;
} }
EXPORT_SYMBOL_GPL(typec_altmode_get_partner); EXPORT_SYMBOL_GPL(typec_altmode_get_partner);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment