public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: u_serial: Add null pointer check in gserial_resume
@ 2023-02-08 13:54 Prashanth K
  2023-02-08 14:54 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 17+ messages in thread
From: Prashanth K @ 2023-02-08 13:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Christophe JAILLET, Xiu Jianfeng
  Cc: Pratham Pratap, Jack Pham, linux-usb, linux-kernel, Prashanth K

Consider a case where gserial_disconnect has already cleared
gser->ioport. And if a wakeup interrupt triggers afterwards,
gserial_resume gets called, which will lead to accessing of
gserial->port and thus causing null pointer dereference.Add
a null pointer check to prevent this.

Fixes: aba3a8d01d62 (" usb: gadget: u_serial: add suspend resume callbacks")
Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
---
 drivers/usb/gadget/function/u_serial.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 840626e..98be2b8 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -1428,6 +1428,9 @@ void gserial_resume(struct gserial *gser)
 	struct gs_port *port = gser->ioport;
 	unsigned long	flags;
 
+	if (!port)
+		return;
+
 	spin_lock_irqsave(&port->port_lock, flags);
 	port->suspended = false;
 	if (!port->start_delayed) {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2023-02-11  6:25 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-08 13:54 [PATCH] usb: gadget: u_serial: Add null pointer check in gserial_resume Prashanth K
2023-02-08 14:54 ` Greg Kroah-Hartman
2023-02-08 15:45   ` Prashanth K
2023-02-08 20:21     ` Alan Stern
2023-02-09  5:01       ` Prashanth K
2023-02-09  7:01         ` Greg Kroah-Hartman
2023-02-09  7:03           ` Prashanth K
2023-02-09 14:07             ` Prashanth K
2023-02-09 15:09               ` Alan Stern
2023-02-09 15:43                 ` Prashanth K
2023-02-09 16:03                   ` Alan Stern
2023-02-09 18:27                     ` Prashanth K
2023-02-09 21:05                       ` Alan Stern
2023-02-10  6:22                         ` Prashanth K
2023-02-10  6:56                           ` Prashanth K
2023-02-10 15:47                             ` Alan Stern
2023-02-11  6:25                               ` Prashanth K

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox