Skip to contentSkip to conversation

devres: Use kmalloc_size_roundup() to match ksize() usage

PATCH New Kees Cook 1 participant 1 message Oct 18, 2022 Driver core

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 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 <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/base/devres.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/devres.c +3 -0
index 4ab2b50ee38f..c0e100074aa3 100644
@@ -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;
 }
 
Signature · 1 line
2.34.1