@samitouri / QOSamiQemu / commits / eb3fb50838

net/tap: check that user tries to define zero queues

Add check for queues parameter to be non-zero, and for fd/fds parameters to be non-empty. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Signed-off-by: Jason Wang <jasowang@redhat.com>

Vladimir Sementsov-Ogievskiy committed Mar 18, 2026 at 14:31 UTC eb3fb508385ce2fc15c738126a1ef5c8b0a19cf4
2 files changed +9
net/tap.c
+4
@@ -807,6 +807,10 @@ static int tap_parse_fds_and_queues(const NetdevTapOptions *tap, int **fds,
807 error_setg(errp, "queues exceeds maximum %d", INT_MAX);
808 return -1;
809 }
810 + if (tap->queues == 0) {
811 + error_setg(errp, "queues must be greater than zero");
812 + return -1;
813 + }
814 queues = tap->queues;
815 *fds = NULL;
816 } else if (tap->fd || tap->fds) {
net/util.c
+5
@@ -94,6 +94,11 @@ int net_parse_fds(const char *fds_param, int **fds, int expected_nfds,
94 return -1;
95 }
96
97 + if (nfds == 0) {
98 + error_setg(errp, "no fds passed");
99 + return -1;
100 + }
101 +
102 *fds = g_new(int, nfds);
103
104 for (i = 0; i < nfds; i++) {