Index: sys/dev/xen/grant_table/grant_table.c =================================================================== --- sys/dev/xen/grant_table/grant_table.c +++ sys/dev/xen/grant_table/grant_table.c @@ -184,6 +184,10 @@ { uint16_t flags, nflags; + if (ref == GRANT_REF_INVALID) { + return (0); + } + nflags = shared[ref].flags; do { if ( (flags = nflags) & (GTF_reading|GTF_writing) ) { @@ -349,8 +353,10 @@ int ref, error; error = get_free_entries(count, &ref); - if (__predict_false(error)) + if (__predict_false(error)) { + *head = GNTTAB_LIST_END; return (error); + } *head = ref; return (0);