ivshmem: limit maximum number of peers to G_MAXUINT16

Limit the maximum number of peers to MAXUINT16. This is more realistic
and better matches the limit of the doorbell register.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
This commit is contained in:
Marc-André Lureau 2015-09-15 16:55:10 +02:00
parent 03977ad552
commit 61ea2d8648
1 changed files with 3 additions and 2 deletions

View File

@ -34,6 +34,7 @@
#define PCI_VENDOR_ID_IVSHMEM PCI_VENDOR_ID_REDHAT_QUMRANET #define PCI_VENDOR_ID_IVSHMEM PCI_VENDOR_ID_REDHAT_QUMRANET
#define PCI_DEVICE_ID_IVSHMEM 0x1110 #define PCI_DEVICE_ID_IVSHMEM 0x1110
#define IVSHMEM_MAX_PEERS G_MAXUINT16
#define IVSHMEM_IOEVENTFD 0 #define IVSHMEM_IOEVENTFD 0
#define IVSHMEM_MSI 1 #define IVSHMEM_MSI 1
@ -421,8 +422,8 @@ static int increase_dynamic_storage(IVShmemState *s, int new_min_size)
int j, old_nb_alloc; int j, old_nb_alloc;
/* check for integer overflow */ /* limit number of max peers */
if (new_min_size >= INT_MAX / sizeof(Peer) - 1 || new_min_size <= 0) { if (new_min_size <= 0 || new_min_size > IVSHMEM_MAX_PEERS) {
return -1; return -1;
} }