Skip to content

Commit f6c7bc4

Browse files
Kuen-Han Tsaigregkh
authored andcommitted
Revert "usb: gadget: u_serial: Add null pointer check in gs_start_io"
This reverts commit ffd603f. Commit ffd603f ("usb: gadget: u_serial: Add null pointer check in gs_start_io") adds null pointer checks at the beginning of the gs_start_io() function to prevent a null pointer dereference. However, these checks are redundant because the function's comment already requires callers to hold the port_lock and ensure port.tty and port_usb are not null. All existing callers already follow these rules. The true cause of the null pointer dereference is a race condition. When gs_start_io() calls either gs_start_rx() or gs_start_tx(), the port_lock is temporarily released for usb_ep_queue(). This allows port.tty and port_usb to be cleared. Fixes: ffd603f ("usb: gadget: u_serial: Add null pointer check in gs_start_io") Cc: stable <[email protected]> Signed-off-by: Kuen-Han Tsai <[email protected]> Reviewed-by: Prashanth K <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 31a6afb commit f6c7bc4

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

drivers/usb/gadget/function/u_serial.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -544,20 +544,16 @@ static int gs_alloc_requests(struct usb_ep *ep, struct list_head *head,
544544
static int gs_start_io(struct gs_port *port)
545545
{
546546
struct list_head *head = &port->read_pool;
547-
struct usb_ep *ep;
547+
struct usb_ep *ep = port->port_usb->out;
548548
int status;
549549
unsigned started;
550550

551-
if (!port->port_usb || !port->port.tty)
552-
return -EIO;
553-
554551
/* Allocate RX and TX I/O buffers. We can't easily do this much
555552
* earlier (with GFP_KERNEL) because the requests are coupled to
556553
* endpoints, as are the packet sizes we'll be using. Different
557554
* configurations may use different endpoints with a given port;
558555
* and high speed vs full speed changes packet sizes too.
559556
*/
560-
ep = port->port_usb->out;
561557
status = gs_alloc_requests(ep, head, gs_read_complete,
562558
&port->read_allocated);
563559
if (status)

0 commit comments

Comments
 (0)