]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xen/gntalloc: make grant counters unsigned
authorYousef Alhouseen <alhouseenyousef@gmail.com>
Fri, 26 Jun 2026 22:38:04 +0000 (00:38 +0200)
committerJuergen Gross <jgross@suse.com>
Wed, 1 Jul 2026 07:58:24 +0000 (09:58 +0200)
The module limit and current allocation count cannot validly be
negative. Give both variables unsigned types so their representation
matches the u32 grant count supplied through the ioctl and negative
module parameter values are rejected by parameter parsing.

This also prepares the limit check for overflow-safe unsigned
arithmetic.

Signed-off-by: Yousef Alhouseen <alhouseenyousef@gmail.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Message-ID: <20260626223805.43781-2-alhouseenyousef@gmail.com>

drivers/xen/gntalloc.c

index eadedd1e963ec74854532bdb39fab9b7fdd14ba4..9279f1521b6f5dba02cedb1c992b0bb0d9a70660 100644 (file)
 #include <xen/gntalloc.h>
 #include <xen/events.h>
 
-static int limit = 1024;
-module_param(limit, int, 0644);
+static unsigned int limit = 1024;
+module_param(limit, uint, 0644);
 MODULE_PARM_DESC(limit, "Maximum number of grants that may be allocated by "
                "the gntalloc device");
 
 static LIST_HEAD(gref_list);
 static DEFINE_MUTEX(gref_mutex);
-static int gref_size;
+static unsigned int gref_size;
 
 struct notify_info {
        uint16_t pgoff:12;    /* Bits 0-11: Offset of the byte to clear */