diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c index 31c2a3130cad..ef79217a903f 100644 --- a/drivers/usb/typec/bus.c +++ b/drivers/usb/typec/bus.c @@ -156,7 +156,20 @@ EXPORT_SYMBOL_GPL(typec_altmode_exit); */ void typec_altmode_attention(struct typec_altmode *adev, u32 vdo) { - struct typec_altmode *pdev = &to_altmode(adev)->partner->adev; + struct altmode *partner = to_altmode(adev)->partner; + struct typec_altmode *pdev; + + /* + * If partner is NULL then a NULL pointer error occurs when + * dereferencing pdev and its operations. The original upstream commit + * changes the return type so the tcpm can log when this occurs, but + * due to KMI restrictions we can only silently prevent the error for + * now. + */ + if (!partner) + return; + + pdev = &partner->adev; if (pdev->ops && pdev->ops->attention) pdev->ops->attention(pdev, vdo);