summaryrefslogtreecommitdiff
path: root/drivers/serial
diff options
context:
space:
mode:
authorxypron.glpk@gmx.de <xypron.glpk@gmx.de>2017-04-15 13:05:46 (GMT)
committerTom Rini <trini@konsulko.com>2017-04-18 14:29:23 (GMT)
commit73be5b3fa73e329ad0d9e12db427cd665e1a483c (patch)
treec4f4521184f4f43b60fc3be70836e8cd93bec09d /drivers/serial
parent6568c731c47bfbb137183f8f745e8168604ea8ab (diff)
downloadu-boot-73be5b3fa73e329ad0d9e12db427cd665e1a483c.tar.xz
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>
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/usbtty.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c
index 2e19813..29799dc 100644
--- a/drivers/serial/usbtty.c
+++ b/drivers/serial/usbtty.c
@@ -850,6 +850,13 @@ static int write_buffer (circbuf_t * buf)
struct urb *current_urb = NULL;
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
*/
if(endpoint->sent < current_urb->actual_length){
@@ -871,12 +878,6 @@ static int write_buffer (circbuf_t * buf)
*/
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 +
current_urb->actual_length;