Re: kernel NULL pointer dereference, ucsi bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 11, 2019 at 10:19:27PM +1000, Vladimir Yerilov wrote:
> Hi Heikki,
> 
> > What do you have connected to the USB Type-C connectors on the
> machine when that happens?
> 
> Now, on 5.2-rc4, it happens only during boot and when power cord is
> connected to laptop's type-c charging port. Another port, which does
> not support charging, does not cause this problem, I mean I can have
> something connected to it or not, no issue is observed if charger is
> disconnected. I even tried to connect my hub to the guilty charging
> port, everything works fine until hub is powered from the charger, in
> that case the bug happens again. This differs from my previous tests
> when whatever I had connected to the charging port, caused failures,
> even type C to A OTG cable. To summarize: now it happens when power
> cord from the charger is connected during the boot, but if I connect
> it after boot (e.g. after logging in to my X session), no crash
> occurs.
> 
> > Can you use the machine normally when nothing is connected to the USB Type-C connectors
> 
> Yeah, everything is great when nothing is connected to the faulty
> charging port during the boot, and charger may be connected later, but
> it's kinda... wrong.
> 
> > Is it possible to send complete dmesg output after that happened?
> 
> You can find everything attached (done with journalctl -k -xb)

Thanks. I don't see anything the driver is doing wrong. I'm attaching
a patch. Can you test if it fixes the issue?

Br,

-- 
heikki
>From d6979950ee911194dab9ae7513fe36dc3730f7a9 Mon Sep 17 00:00:00 2001
From: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>
Date: Tue, 11 Jun 2019 11:10:25 +0300
Subject: [PATCH] usb: typec: Make sure an alt mode exist before getting its
 partner

Interim. For testing only!

Adding check to typec_altmode_get_partner() to prevent
potential NULL pointer dereference.

Signed-off-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>
---
 drivers/usb/typec/bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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);
 
-- 
2.20.1


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux