* [PATCH 1/2] xenmon: close qos_fd when finished with it in alloc_qos_data
@ 2016-02-10 16:26 Ian Campbell
2016-02-10 16:26 ` [PATCH 2/2] xenmon: initialise dummy array Ian Campbell
2016-02-11 11:18 ` [PATCH 1/2] xenmon: close qos_fd when finished with it in alloc_qos_data Wei Liu
0 siblings, 2 replies; 5+ messages in thread
From: Ian Campbell @ 2016-02-10 16:26 UTC (permalink / raw)
To: ian.jackson, wei.liu2, xen-devel; +Cc: 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 <ian.campbell@citrix.com>
---
tools/xenmon/xenbaked.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/xenmon/xenbaked.c b/tools/xenmon/xenbaked.c
index eacacb0..782f0c1 100644
--- a/tools/xenmon/xenbaked.c
+++ b/tools/xenmon/xenbaked.c
@@ -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;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] xenmon: initialise dummy array
2016-02-10 16:26 [PATCH 1/2] xenmon: close qos_fd when finished with it in alloc_qos_data Ian Campbell
@ 2016-02-10 16:26 ` Ian Campbell
2016-02-11 11:19 ` Wei Liu
2016-02-11 11:18 ` [PATCH 1/2] xenmon: close qos_fd when finished with it in alloc_qos_data Wei Liu
1 sibling, 1 reply; 5+ messages in thread
From: Ian Campbell @ 2016-02-10 16:26 UTC (permalink / raw)
To: ian.jackson, wei.liu2, xen-devel; +Cc: 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.
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 <ian.campbell@citrix.com>
---
tools/xenmon/xenbaked.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/xenmon/xenbaked.c b/tools/xenmon/xenbaked.c
index 782f0c1..3d9e0ed 100644
--- a/tools/xenmon/xenbaked.c
+++ b/tools/xenmon/xenbaked.c
@@ -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++) {
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] xenmon: close qos_fd when finished with it in alloc_qos_data
2016-02-10 16:26 [PATCH 1/2] xenmon: close qos_fd when finished with it in alloc_qos_data Ian Campbell
2016-02-10 16:26 ` [PATCH 2/2] xenmon: initialise dummy array Ian Campbell
@ 2016-02-11 11:18 ` Wei Liu
2016-02-11 15:38 ` Ian Campbell
1 sibling, 1 reply; 5+ messages in thread
From: Wei Liu @ 2016-02-11 11:18 UTC (permalink / raw)
To: Ian Campbell; +Cc: wei.liu2, ian.jackson, xen-devel
On Wed, Feb 10, 2016 at 04:26:24PM +0000, Ian Campbell wrote:
> 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 <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
> ---
> tools/xenmon/xenbaked.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/xenmon/xenbaked.c b/tools/xenmon/xenbaked.c
> index eacacb0..782f0c1 100644
> --- a/tools/xenmon/xenbaked.c
> +++ b/tools/xenmon/xenbaked.c
> @@ -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;
> }
>
> --
> 2.1.4
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] xenmon: initialise dummy array
2016-02-10 16:26 ` [PATCH 2/2] xenmon: initialise dummy array Ian Campbell
@ 2016-02-11 11:19 ` Wei Liu
0 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2016-02-11 11:19 UTC (permalink / raw)
To: Ian Campbell; +Cc: wei.liu2, ian.jackson, xen-devel
On Wed, Feb 10, 2016 at 04:26:25PM +0000, Ian Campbell wrote:
> 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)
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
> ---
> tools/xenmon/xenbaked.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/tools/xenmon/xenbaked.c b/tools/xenmon/xenbaked.c
> index 782f0c1..3d9e0ed 100644
> --- a/tools/xenmon/xenbaked.c
> +++ b/tools/xenmon/xenbaked.c
> @@ -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++) {
>
> --
> 2.1.4
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] xenmon: close qos_fd when finished with it in alloc_qos_data
2016-02-11 11:18 ` [PATCH 1/2] xenmon: close qos_fd when finished with it in alloc_qos_data Wei Liu
@ 2016-02-11 15:38 ` Ian Campbell
0 siblings, 0 replies; 5+ messages in thread
From: Ian Campbell @ 2016-02-11 15:38 UTC (permalink / raw)
To: Wei Liu; +Cc: ian.jackson, xen-devel
On Thu, 2016-02-11 at 11:18 +0000, Wei Liu wrote:
> On Wed, Feb 10, 2016 at 04:26:24PM +0000, Ian Campbell wrote:
> > 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 <ian.campbell@citrix.com>
>
> Acked-by: Wei Liu <wei.liu2@citrix.com>
Applied both, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-02-11 15:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-10 16:26 [PATCH 1/2] xenmon: close qos_fd when finished with it in alloc_qos_data Ian Campbell
2016-02-10 16:26 ` [PATCH 2/2] xenmon: initialise dummy array Ian Campbell
2016-02-11 11:19 ` Wei Liu
2016-02-11 11:18 ` [PATCH 1/2] xenmon: close qos_fd when finished with it in alloc_qos_data Wei Liu
2016-02-11 15:38 ` Ian Campbell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).