]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drivers/xen: use min() instead of min_t()
authorDavid Laight <david.laight.linux@gmail.com>
Wed, 19 Nov 2025 22:41:25 +0000 (22:41 +0000)
committerJuergen Gross <jgross@suse.com>
Fri, 5 Dec 2025 07:46:07 +0000 (08:46 +0100)
min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'.
Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long'
and so cannot discard significant bits.

In this case the 'unsigned long' value is small enough that the result
is ok.

Detected by an extra check added to min_t().

Signed-off-by: David Laight <david.laight.linux@gmail.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Message-ID: <20251119224140.8616-30-david.laight.linux@gmail.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
drivers/xen/grant-table.c

index 478d2ad725ac6bc522532ffd31af791793f1ff49..3e76e33f6e08e6249b962b7174d0217e876da3e0 100644 (file)
@@ -1204,7 +1204,7 @@ void gnttab_foreach_grant_in_range(struct page *page,
        unsigned int glen;
        unsigned long xen_pfn;
 
-       len = min_t(unsigned int, PAGE_SIZE - offset, len);
+       len = min(PAGE_SIZE - offset, len);
        goffset = xen_offset_in_page(offset);
 
        xen_pfn = page_to_xen_pfn(page) + XEN_PFN_DOWN(offset);