xen/grant-table: never put a reserved grant on the free list
authorJuergen Gross <jgross@suse.com>
Thu, 5 May 2022 06:35:31 +0000 (08:35 +0200)
committerJuergen Gross <jgross@suse.com>
Thu, 19 May 2022 12:21:37 +0000 (14:21 +0200)
Make sure a reserved grant is never put on the free list, as this could
cause hard to debug errors.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
drivers/xen/grant-table.c

index 6ea31ea..1a1aec0 100644 (file)
@@ -207,6 +207,10 @@ static inline void check_free_callbacks(void)
 static void put_free_entry(grant_ref_t ref)
 {
        unsigned long flags;
+
+       if (unlikely(ref < GNTTAB_NR_RESERVED_ENTRIES))
+               return;
+
        spin_lock_irqsave(&gnttab_list_lock, flags);
        gnttab_entry(ref) = gnttab_free_head;
        gnttab_free_head = ref;