usb: typec: altmode: Fix typec_altmode_get_partner sometimes returning an invalid...
authorNaoki Kiryu <naonaokiryu2@gmail.com>
Wed, 22 Apr 2020 14:43:45 +0000 (16:43 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Apr 2020 17:23:19 +0000 (19:23 +0200)
commit0df9433fcae02215c8fd79690c134d535c7bb905
tree6d4df89139095e50945dd8056e80a4b95ac74ec5
parent8f97250c21f0cf36434bf5b7ddf4377406534cd1
usb: typec: altmode: Fix typec_altmode_get_partner sometimes returning an invalid pointer

Before this commit, typec_altmode_get_partner would return a
const struct typec_altmode * pointing to address 0x08 when
to_altmode(adev)->partner was NULL.

Add a check for to_altmode(adev)->partner being NULL to fix this.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206365
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1785972
Fixes: 5f54a85db5df ("usb: typec: Make sure an alt mode exist before getting its partner")
Cc: stable@vger.kernel.org
Signed-off-by: Naoki Kiryu <naonaokiryu2@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20200422144345.43262-1-hdegoede@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/bus.c