diff options
author | Daniel Verkamp <dverkamp@chromium.org> | 2019-10-14 15:21:50 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-10-25 17:49:40 +0000 |
commit | 7f64f5030b40acded00631465cc3f8b122317b04 (patch) | |
tree | e618b69017caf335d30411f810b908de7270912c /devices/src/virtio/balloon.rs | |
parent | 67bdbc1a57a6e62a5d162d8eb43508b20fd0acda (diff) | |
download | crosvm-7f64f5030b40acded00631465cc3f8b122317b04.tar crosvm-7f64f5030b40acded00631465cc3f8b122317b04.tar.gz crosvm-7f64f5030b40acded00631465cc3f8b122317b04.tar.bz2 crosvm-7f64f5030b40acded00631465cc3f8b122317b04.tar.lz crosvm-7f64f5030b40acded00631465cc3f8b122317b04.tar.xz crosvm-7f64f5030b40acded00631465cc3f8b122317b04.tar.zst crosvm-7f64f5030b40acded00631465cc3f8b122317b04.zip |
descriptor_utils: check for size overflow in new()
Move the check for length overflow that was in available_bytes() into Reader::new() and Writer::new(). This simplifies callers, since they can assume that once a valid Reader or Writer has been constructed, available_bytes() cannot fail. Since we are walking the descriptor chain during new() anyway, this extra check should be essentially free. BUG=None TEST=cargo test -p devices descriptor_utils Change-Id: Ibeb1defd3728e7b71356650094b0885f3419ed47 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1873142 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Stephen Barber <smbarber@chromium.org>
Diffstat (limited to 'devices/src/virtio/balloon.rs')
-rw-r--r-- | devices/src/virtio/balloon.rs | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/devices/src/virtio/balloon.rs b/devices/src/virtio/balloon.rs index 4f2e692..460aba5 100644 --- a/devices/src/virtio/balloon.rs +++ b/devices/src/virtio/balloon.rs @@ -105,15 +105,7 @@ impl Worker { continue; } }; - let data_length = match reader.available_bytes() { - Ok(l) => l, - Err(e) => { - error!("balloon: failed to get available bytes: {}", e); - queue.add_used(&self.mem, index, 0); - needs_interrupt = true; - continue; - } - }; + let data_length = reader.available_bytes(); if data_length % 4 != 0 { error!("invalid inflate buffer size: {}", data_length); |