KVM: use struct_size() and flex_array_size() helpers in kvm_io_bus_unregister_dev()
authorRustam Kovhaev <rkovhaev@gmail.com>
Fri, 18 Sep 2020 12:05:00 +0000 (05:05 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 28 Sep 2020 11:57:17 +0000 (07:57 -0400)
commit871c433bae565306cfc3a1a386bf7328bc9d31cb
tree4119e67682745c57af5cd6e1426f1312cabce2b1
parent4407a797e9412afba2f7815fb19395d4b32dca4e
KVM: use struct_size() and flex_array_size() helpers in kvm_io_bus_unregister_dev()

Make use of the struct_size() helper to avoid any potential type
mistakes and protect against potential integer overflows
Make use of the flex_array_size() helper to calculate the size of a
flexible array member within an enclosing structure

Suggested-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Rustam Kovhaev <rkovhaev@gmail.com>
Message-Id: <20200918120500.954436-1-rkovhaev@gmail.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virt/kvm/kvm_main.c