]> xenbits.xensource.com Git - pvdrivers/win/xenvif.git/commitdiff
Check for zero byte allocations
authorOwen Smith <owen.smith@cloud.com>
Mon, 17 Apr 2023 14:32:46 +0000 (15:32 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Mon, 22 May 2023 12:36:17 +0000 (13:36 +0100)
Avoid attempting to allocate zero byte buffers, which can lead to
inefficiencies in pool memory usage.

Suggested-by: Matthew Sykes <matthew.sykes@citrix.com>
Signed-off-by: Owen Smith <owen.smith@cloud.com>
src/xenvif/util.h

index 370d45a3ac612c5ca586f3c13b5d1608cafbb578..b08584245612fe75988ae54c7d72b0872a34021d 100644 (file)
@@ -153,6 +153,9 @@ __AllocatePoolWithTag(
     __analysis_assume(PoolType == NonPagedPool ||
                       PoolType == PagedPool);
 
+    if (NumberOfBytes == 0)
+        return NULL;
+
 #if (_MSC_VER >= 1928) // VS 16.9 (EWDK 20344 or later)
     Buffer = ExAllocatePoolUninitialized(PoolType, NumberOfBytes, Tag);
 #else