From: Kees Cook Date: Tue, 18 Oct 2022 09:04:10 +0000 (-0700) Subject: devres: Use kmalloc_size_roundup() to match ksize() usage X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=6fcd7e702d3d91cc2c3194acffd7d67b2c10b81f;p=linux.git devres: Use kmalloc_size_roundup() to match ksize() usage Round up allocations with kmalloc_size_roundup() so that devres's use of ksize() is always accurate and no special handling of the memory is needed by KASAN, UBSAN_BOUNDS, nor FORTIFY_SOURCE. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20221018090406.never.856-kees@kernel.org Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/base/devres.c b/drivers/base/devres.c index 4ab2b50ee38f4..c0e100074aa39 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -101,6 +101,9 @@ static bool check_dr_size(size_t size, size_t *tot_size) size, tot_size))) return false; + /* Actually allocate the full kmalloc bucket size. */ + *tot_size = kmalloc_size_roundup(*tot_size); + return true; }