From 2747989d9e838a5619fee37f70f5ffbcc7e82c55 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 31 Aug 2014 10:56:32 +0200 Subject: [PATCH] USB: Warn if debug allocation does not fit debug chunk size. --- .../kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp b/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp index 5ef971b325..7ec36484af 100644 --- a/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp +++ b/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "BeOSCompatibility.h" #include "PhysicalMemoryAllocator.h" @@ -133,6 +134,13 @@ PhysicalMemoryAllocator::Allocate(size_t size, void **logicalAddress, { #ifdef HAIKU_TARGET_PLATFORM_HAIKU if (debug_debugger_running()) { + if (size > fDebugChunkSize) { + kprintf("usb allocation of %" B_PRIuSIZE + " does not fit debug chunk size %" B_PRIuSIZE "!\n", + size, fDebugChunkSize); + return B_NO_MEMORY; + } + for (int32 i = 0; i < 64; i++) { uint64 mask = 1LL << i; if ((fDebugUseMap & mask) == 0) {