1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-07 21:17:55 +03:00

util: numa: Catch readdir errors in virNumaGetPages

Don't return possibly incomplete result if virDirRead fails.
This commit is contained in:
Peter Krempa 2014-06-23 09:10:04 +02:00
parent 42d75b44ba
commit 00b2317a66

View File

@ -728,6 +728,7 @@ virNumaGetPages(int node,
int ret = -1;
char *path = NULL;
DIR *dir = NULL;
int direrr;
struct dirent *entry;
unsigned int *tmp_size = NULL, *tmp_avail = NULL, *tmp_free = NULL;
unsigned int ntmp = 0;
@ -768,7 +769,7 @@ virNumaGetPages(int node,
goto cleanup;
}
while (virDirRead(dir, &entry, path) > 0) {
while ((direrr = virDirRead(dir, &entry, path)) > 0) {
const char *page_name = entry->d_name;
unsigned int page_size, page_avail = 0, page_free = 0;
char *end;
@ -805,6 +806,9 @@ virNumaGetPages(int node,
ntmp++;
}
if (direrr < 0)
goto cleanup;
/* Just to produce nice output, sort the arrays by increasing page size */
do {
exchange = false;