summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>2019-06-12 17:15:40 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-06-12 17:13:02 +0200
commit5f54a85db5df67df8161739a4b2f9c2b7ab219fe (patch)
tree527ddbb225b264ec03b33217e0c89b67c4bab33f
parentc2ed3d474fac61ab46468c5365f84f59dc6e173f (diff)
downloadlinux-5f54a85db5df67df8161739a4b2f9c2b7ab219fe.tar.bz2
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: Vladimir Yerilov <openmindead@gmail.com> Fixes: ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/typec/bus.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c
index 76299b6ff06d..74cb3c2ecb34 100644
--- a/drivers/usb/typec/bus.c
+++ b/drivers/usb/typec/bus.c
@@ -192,7 +192,7 @@ EXPORT_SYMBOL_GPL(typec_altmode_vdm);
const struct typec_altmode *
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);