mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-11-07 04:36:52 -10:00
bhyve: Fix virtio-input event array resizing
Use the new array size when calling realloc(). Note that this queue
stores events read from a host evdev device, i.e., it is not
guest-controlled.
While here, use the cdefs.h __unused macro and use them correctly, i.e.,
don't mark "arg" as unused when it isn't.
Reported by: Brian Delgado from Intel using Anthropic Opus 4.8
Fixes: 054accac71 ("Add a virtio-input device emulation.")
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D60679
This commit is contained in:
1 parent
55d0e022fb
commit
f1986e5b88
1 file changed
+7
-13
@@ -467,19 +467,14 @@ static int
|
||||
vtinput_eventqueue_add_event(
|
||||
struct vtinput_eventqueue *queue, struct input_event *e)
|
||||
{
|
||||
/* check if queue is full */
|
||||
if (queue->idx >= queue->size) {
|
||||
/* alloc new elements for queue */
|
||||
const uint32_t newSize = queue->idx;
|
||||
void *newPtr = realloc(queue->events,
|
||||
queue->size * sizeof(struct vtinput_event_elem));
|
||||
if (newPtr == NULL) {
|
||||
WPRINTF(("%s: realloc memory for eventqueue failed!",
|
||||
__func__));
|
||||
const size_t nsize = queue->idx + VTINPUT_MAX_PKT_LEN;
|
||||
void *ptr = realloc(queue->events,
|
||||
nsize * sizeof(struct vtinput_event_elem));
|
||||
if (ptr == NULL)
|
||||
return (1);
|
||||
}
|
||||
queue->events = newPtr;
|
||||
queue->size = newSize;
|
||||
queue->events = ptr;
|
||||
queue->size = nsize;
|
||||
}
|
||||
|
||||
/* save event */
|
||||
@@ -584,8 +579,7 @@ vtinput_read_event_from_host(int fd, struct input_event *event)
|
||||
}
|
||||
|
||||
static void
|
||||
vtinput_read_event(int fd __attribute((unused)),
|
||||
enum ev_type t __attribute__((unused)), void *arg __attribute__((unused)))
|
||||
vtinput_read_event(int fd __unused, enum ev_type t __unused, void *arg)
|
||||
{
|
||||
struct pci_vtinput_softc *sc = arg;
|
||||
|
||||
|
||||
Reference in new issue
Block a user