From 746569350f292897f3114599fec202b31b032863 Mon Sep 17 00:00:00 2001 From: Elson Roy Serrao Date: Thu, 4 Mar 2021 17:54:03 -0800 Subject: [PATCH] usb: f_qdss: Do not perform connect_work if qdss is closed When qdss open and close are called back to back at a high rate, connect_work that gets queued in qdss open can execute after qdss close. For qdss HW path the connect work that gets scheduled as part of the next qdss open results in ep config failure as the ep is already configured during previous connect work. Now before queuing the request if there is a qdss close it would reset the dbm ep configuration thus routing this request via software path instead of dbm path. The subsequent dequeue would lead to a NULL pointer dereference of completion callback. Fix this by preventing execution of connect work after qdss close. Change-Id: If710ede85b4265ddbfd9ccdd8d040c6693efc330 Signed-off-by: Elson Roy Serrao --- drivers/usb/gadget/function/f_qdss.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/function/f_qdss.c b/drivers/usb/gadget/function/f_qdss.c index 8d8ed9fb0812..034d1561f596 100644 --- a/drivers/usb/gadget/function/f_qdss.c +++ b/drivers/usb/gadget/function/f_qdss.c @@ -2,7 +2,7 @@ /* * f_qdss.c -- QDSS function Driver * - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #include @@ -591,8 +591,8 @@ static void usb_qdss_connect_work(struct work_struct *work) qdss = container_of(work, struct f_qdss, connect_w); - /* If cable is already removed, discard connect_work */ - if (qdss->usb_connected == 0) { + /* If qdss is closed or cable is removed, discard connect_work */ + if (qdss->qdss_close || qdss->usb_connected == 0) { cancel_work_sync(&qdss->disconnect_w); return; }