usbtty: avoid potential NULL pointer dereference
If current_urb is NULL it should not be dereferenced. The problem was indicated by cppcheck. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
6568c731c4
commit
73be5b3fa7
@ -850,6 +850,13 @@ static int write_buffer (circbuf_t * buf)
|
|||||||
struct urb *current_urb = NULL;
|
struct urb *current_urb = NULL;
|
||||||
|
|
||||||
current_urb = next_urb (device_instance, endpoint);
|
current_urb = next_urb (device_instance, endpoint);
|
||||||
|
|
||||||
|
if (!current_urb) {
|
||||||
|
TTYERR ("current_urb is NULL, buf->size %d\n",
|
||||||
|
buf->size);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* TX data still exists - send it now
|
/* TX data still exists - send it now
|
||||||
*/
|
*/
|
||||||
if(endpoint->sent < current_urb->actual_length){
|
if(endpoint->sent < current_urb->actual_length){
|
||||||
@ -871,12 +878,6 @@ static int write_buffer (circbuf_t * buf)
|
|||||||
*/
|
*/
|
||||||
while (buf->size > 0) {
|
while (buf->size > 0) {
|
||||||
|
|
||||||
if (!current_urb) {
|
|
||||||
TTYERR ("current_urb is NULL, buf->size %d\n",
|
|
||||||
buf->size);
|
|
||||||
return total;
|
|
||||||
}
|
|
||||||
|
|
||||||
dest = (char*)current_urb->buffer +
|
dest = (char*)current_urb->buffer +
|
||||||
current_urb->actual_length;
|
current_urb->actual_length;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user