Fix for possible null pointer dereference in keyspan.c
Subsystems (3)
PATCH 1/1 Fix for possible null pointer dereference in keyspan.c
There is otherwise a risk of a possible null pointer dereference.
Was largely found by using a static code analysis program called cppcheck.
--- drivers/usb/serial/keyspan.c | 4 ++--
1 fil ändrad, 2 tillägg(+), 2 borttagningar(-)
drivers/usb/serial/keyspan.c +2 -2
@@ -1535,14 +1535,14 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, this_urb = p_priv->outcont_urb; -dev_dbg (&port->dev,"%s - endpoint %d\n" , __func__,usb_pipeendpoint (this_urb->pipe)); -/* Make sure we have an urb then send the message */ if (this_urb ==NULL ) {dev_dbg (&port->dev,"%s - oops no urb.\n" , __func__);return -1 ; } +dev_dbg (&port->dev,"%s - endpoint %d\n" , __func__,usb_pipeendpoint (this_urb->pipe)); +/* Save reset port val for resend. Don't overwrite resend for open/close condition. */ if ((reset_port +1 ) > p_priv->resend_cont)
Signature · 1 line
1.7.10.4
Quoted 1 line · Rickard Strandqvist
There is otherwise a risk of a possible null pointer dereference.
I don't think this can be triggered unless the URB allocation fails at probe, but let's move the offending line nonetheless.
I'll fix up the patch subject as well.
Quoted 6 lines
Was largely found by using a static code analysis program called cppcheck.
Signed-off-by Rickard Strandqvist <[email protected]>--- drivers/usb/serial/keyspan.c | 4 ++--1 fil ändrad, 2 tillägg(+), 2 borttagningar(-)
Diff stats in Swedish?! :)
Thanks,
Johan
Quoted 21 lines
drivers/usb/serial/keyspan.c +2
-2@@ -1535,14 +1535,14 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, this_urb = p_priv->outcont_urb; -dev_dbg (&port->dev,"%s - endpoint %d\n" , __func__,usb_pipeendpoint (this_urb->pipe)); -/* Make sure we have an urb then send the message */ if (this_urb ==NULL ) {dev_dbg (&port->dev,"%s - oops no urb.\n" , __func__);return -1 ; } +dev_dbg (&port->dev,"%s - endpoint %d\n" , __func__,usb_pipeendpoint (this_urb->pipe)); +/* Save reset port val for resend. Don't overwrite resend for open/close condition. */ if ((reset_port +1 ) > p_priv->resend_cont)
PATCH 1/1 USB: keyspan: fix potential null pointer dereference
From: Rickard Strandqvist <[email protected]>
Move control-urb dereference to after NULL-check. There is otherwise a risk of a possible null pointer dereference.
Was largely found by using a static code analysis program called cppcheck.
[Johan: modify commit message somewhat ]
--- drivers/usb/serial/keyspan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/serial/keyspan.c +2 -2
@@ -1535,14 +1535,14 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial, this_urb = p_priv->outcont_urb; -dev_dbg (&port->dev,"%s - endpoint %d\n" , __func__,usb_pipeendpoint (this_urb->pipe)); -/* Make sure we have an urb then send the message */ if (this_urb ==NULL ) {dev_dbg (&port->dev,"%s - oops no urb.\n" , __func__);return -1 ; } +dev_dbg (&port->dev,"%s - endpoint %d\n" , __func__,usb_pipeendpoint (this_urb->pipe)); +/* Save reset port val for resend. Don't overwrite resend for open/close condition. */ if ((reset_port +1 ) > p_priv->resend_cont)
Signature · 1 line
1.8.5.5