usb: gadget: u_serial: Add null pointer check in gserial_resume
authorPrashanth K <quic_prashk@quicinc.com>
Mon, 13 Feb 2023 17:30:38 +0000 (23:00 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Feb 2023 13:41:32 +0000 (14:41 +0100)
commit5ec63fdbca604568890c577753c6f66c5b3ef0b5
tree3d6f4add2c406a79c571ed405b7c1e9c800a16c9
parent7ebb605d2283fb2647b4fa82030307ce00bee436
usb: gadget: u_serial: Add null pointer check in gserial_resume

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
gser->ioport and thus causing null pointer dereference.Add
a null pointer check to prevent this.

Added a static spinlock to prevent gser->ioport from becoming
null after the newly added check.

Fixes: aba3a8d01d62 ("usb: gadget: u_serial: add suspend resume callbacks")
Cc: stable <stable@kernel.org>
Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/1676309438-14922-1-git-send-email-quic_prashk@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/u_serial.c