diff options
| author | Linux Build Service Account <lnxbuild@localhost> | 2018-06-21 13:37:41 -0700 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2018-06-21 13:37:40 -0700 |
| commit | ea54b9e53069c8b28e2d0b1ff5594eba689efa56 (patch) | |
| tree | d42a5d4453cf93b51ed3ecad6d0718fe4b7e3a95 /drivers/char | |
| parent | 71277408de8d0e2b89f0533d93e30e924de52715 (diff) | |
| parent | 4b3d87497bf25fa89904d3e5d1ce3e0867ca1de6 (diff) | |
Merge "diag: Add NULL pointer check for write buffer of fwd_info"
Diffstat (limited to 'drivers/char')
| -rw-r--r-- | drivers/char/diag/diagfwd_peripheral.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/char/diag/diagfwd_peripheral.c b/drivers/char/diag/diagfwd_peripheral.c index 6b74c0056d1b..6f240cacff58 100644 --- a/drivers/char/diag/diagfwd_peripheral.c +++ b/drivers/char/diag/diagfwd_peripheral.c @@ -1106,8 +1106,11 @@ void *diagfwd_request_write_buf(struct diagfwd_info *fwd_info) int index; unsigned long flags; + if (!fwd_info) + return NULL; spin_lock_irqsave(&fwd_info->write_buf_lock, flags); - for (index = 0 ; index < NUM_WRITE_BUFFERS; index++) { + for (index = 0; (index < NUM_WRITE_BUFFERS) && fwd_info->buf_ptr[index]; + index++) { if (!atomic_read(&(fwd_info->buf_ptr[index]->in_busy))) { atomic_set(&(fwd_info->buf_ptr[index]->in_busy), 1); buf = fwd_info->buf_ptr[index]->data; @@ -1529,7 +1532,8 @@ int diagfwd_write_buffer_done(struct diagfwd_info *fwd_info, const void *ptr) if (!fwd_info || !ptr) return found; spin_lock_irqsave(&fwd_info->write_buf_lock, flags); - for (index = 0; index < NUM_WRITE_BUFFERS; index++) { + for (index = 0; (index < NUM_WRITE_BUFFERS) && fwd_info->buf_ptr[index]; + index++) { if (fwd_info->buf_ptr[index]->data == ptr) { atomic_set(&fwd_info->buf_ptr[index]->in_busy, 0); found = 1; |
