xenmon: close qos_fd when finished with it in alloc_qos_data
PATCH 1/2 xenmon: close qos_fd when finished with it in alloc_qos_data
Otherwise the fd is leaked. NB the mmap'd memory in the global cpu_qos_data[n] is not affected by closing the underlying fd.
Compile tested only.
CID: 1055930
--- tools/xenmon/xenbaked.c | 1 + 1 file changed, 1 insertion(+)
tools/xenmon/xenbaked.c +1 -0
@@ -689,6 +689,7 @@ static void alloc_qos_data(int ncpu) cpu_qos_data[n] = new_qos; }free (dummy); +close (qos_fd); new_qos =NULL ; }
Signature · 1 line
2.1.4
PATCH 2/2 xenmon: initialise dummy array
This is just used to expand the shared backing file to the expected size (whether this is actually necessary I'm not sure). Rather than leaking some small amount of the processes' heap set the array to zeroes.
While at it add a check that the malloc succeeded before using the result.
Compile tested only.
CID: 1056095 (use of uninitialised data)
--- tools/xenmon/xenbaked.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/xenmon/xenbaked.c +5 -0
@@ -663,6 +663,11 @@ static void alloc_qos_data(int ncpu) } pgsize =getpagesize (); dummy =malloc (pgsize); +if (!dummy) { +PERROR ("malloc" ); +exit (EXIT_FAILURE ); + } +memset (dummy,0 , pgsize);for (n=0 ; n<ncpu; n++) {
Signature · 1 line
2.1.4
Re: [PATCH 2/2] xenmon: initialise dummy array
Quoted 5 lines · Ian Campbell
This is just used to expand the shared backing file to the expected size (whether this is actually necessary I'm not sure). Rather than leaking some small amount of the processes' heap set the array to zeroes.
Quoted 8 lines
While at it add a check that the malloc succeeded before using the result.
Compile tested only.
CID: 1056095 (use of uninitialised data)
Signed-off-by Ian Campbell <[email protected]>
Quoted 23 lines
--- tools/xenmon/xenbaked.c | 5 +++++ 1 file changed, 5 insertions(+)tools/xenmon/xenbaked.c +5
-0@@ -663,6 +663,11 @@ static void alloc_qos_data(int ncpu) } pgsize =getpagesize (); dummy =malloc (pgsize); +if (!dummy) { +PERROR ("malloc" ); +exit (EXIT_FAILURE ); + } +memset (dummy,0 , pgsize);for (n=0 ; n<ncpu; n++) {Signature · 1 line
2.1.4
Quoted 8 lines · Ian Campbell
Otherwise the fd is leaked. NB the mmap'd memory in the global cpu_qos_data[n] is not affected by closing the underlying fd.
Compile tested only.
CID: 1055930
Signed-off-by Ian Campbell <[email protected]>
Quoted 19 lines
--- tools/xenmon/xenbaked.c | 1 + 1 file changed, 1 insertion(+)tools/xenmon/xenbaked.c +1
-0@@ -689,6 +689,7 @@ static void alloc_qos_data(int ncpu) cpu_qos_data[n] = new_qos; }free (dummy); +close (qos_fd); new_qos =NULL ; }Signature · 1 line
2.1.4
Ian Campbell
AppliedQuoted 11 lines · Wei Liu
Quoted 8 lines · Ian Campbell
Otherwise the fd is leaked. NB the mmap'd memory in the global cpu_qos_data[n] is not affected by closing the underlying fd.
Compile tested only.
CID: 1055930
Signed-off-by Ian Campbell <[email protected]>Acked-by Wei Liu <[email protected]>
Applied both, thanks.