Skip to content

Commit

Permalink
USB: keyspan: fix null-deref at probe
Browse files Browse the repository at this point in the history
commit b5122236bba8d7ef62153da5b55cc65d0944c61e upstream.

Fix null-pointer dereference during probe if the interface-status
completion handler is called before the individual ports have been set
up.

Fixes: f79b2d0 ("USB: keyspan: fix NULL-pointer dereferences and
memory leaks")
Reported-by: Richard <[email protected]>
Tested-by: Richard <[email protected]>
Signed-off-by: Johan Hovold <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
jhovold authored and gregkh committed Jan 27, 2015
1 parent a1fec58 commit a696260
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions drivers/usb/serial/keyspan.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ static void usa26_instat_callback(struct urb *urb)
}
port = serial->port[msg->port];
p_priv = usb_get_serial_port_data(port);
if (!p_priv)
goto resubmit;

/* Update handshaking pin state information */
old_dcd_state = p_priv->dcd_state;
Expand All @@ -431,7 +433,7 @@ static void usa26_instat_callback(struct urb *urb)

if (old_dcd_state != p_priv->dcd_state)
tty_port_tty_hangup(&port->port, true);

resubmit:
/* Resubmit urb so we continue receiving */
err = usb_submit_urb(urb, GFP_ATOMIC);
if (err != 0)
Expand Down Expand Up @@ -541,6 +543,8 @@ static void usa28_instat_callback(struct urb *urb)
}
port = serial->port[msg->port];
p_priv = usb_get_serial_port_data(port);
if (!p_priv)
goto resubmit;

/* Update handshaking pin state information */
old_dcd_state = p_priv->dcd_state;
Expand All @@ -551,7 +555,7 @@ static void usa28_instat_callback(struct urb *urb)

if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
tty_port_tty_hangup(&port->port, true);

resubmit:
/* Resubmit urb so we continue receiving */
err = usb_submit_urb(urb, GFP_ATOMIC);
if (err != 0)
Expand Down Expand Up @@ -624,6 +628,8 @@ static void usa49_instat_callback(struct urb *urb)
}
port = serial->port[msg->portNumber];
p_priv = usb_get_serial_port_data(port);
if (!p_priv)
goto resubmit;

/* Update handshaking pin state information */
old_dcd_state = p_priv->dcd_state;
Expand All @@ -634,7 +640,7 @@ static void usa49_instat_callback(struct urb *urb)

if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
tty_port_tty_hangup(&port->port, true);

resubmit:
/* Resubmit urb so we continue receiving */
err = usb_submit_urb(urb, GFP_ATOMIC);
if (err != 0)
Expand Down Expand Up @@ -872,6 +878,8 @@ static void usa90_instat_callback(struct urb *urb)

port = serial->port[0];
p_priv = usb_get_serial_port_data(port);
if (!p_priv)
goto resubmit;

/* Update handshaking pin state information */
old_dcd_state = p_priv->dcd_state;
Expand All @@ -882,7 +890,7 @@ static void usa90_instat_callback(struct urb *urb)

if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
tty_port_tty_hangup(&port->port, true);

resubmit:
/* Resubmit urb so we continue receiving */
err = usb_submit_urb(urb, GFP_ATOMIC);
if (err != 0)
Expand Down Expand Up @@ -943,6 +951,8 @@ static void usa67_instat_callback(struct urb *urb)

port = serial->port[msg->port];
p_priv = usb_get_serial_port_data(port);
if (!p_priv)
goto resubmit;

/* Update handshaking pin state information */
old_dcd_state = p_priv->dcd_state;
Expand All @@ -951,7 +961,7 @@ static void usa67_instat_callback(struct urb *urb)

if (old_dcd_state != p_priv->dcd_state && old_dcd_state)
tty_port_tty_hangup(&port->port, true);

resubmit:
/* Resubmit urb so we continue receiving */
err = usb_submit_urb(urb, GFP_ATOMIC);
if (err != 0)
Expand Down

0 comments on commit a696260

Please sign in to comment.