]> xenbits.xensource.com Git - xen.git/commit
libs/guest: Fix leak on realloc failure in backup_ptes()
authorEdwin Török <edwin.torok@cloud.com>
Fri, 24 Feb 2023 13:03:44 +0000 (13:03 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 27 Feb 2023 15:51:23 +0000 (15:51 +0000)
commit275d13184cfa52ebe4336ed66526ce93716adbe0
tree7fba44e6fefdf38387f211b101db207e267d9c5a
parent1868d7f22660c8980bd0a7e53f044467e8b63bb5
libs/guest: Fix leak on realloc failure in backup_ptes()

From `man 2 realloc`:

  If realloc() fails, the original block is left untouched; it is not freed or moved.

Found using GCC -fanalyzer:

  |  184 |         backup->entries = realloc(backup->entries,
  |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  |      |         |               | |
  |      |         |               | (91) when ‘realloc’ fails
  |      |         |               (92) ‘old_ptes.entries’ leaks here; was allocated at (44)
  |      |         (90) ...to here

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/libs/guest/xg_offline_page.c