Re: [PATCH spice-server v3 5/6] Avoid leaking file descriptor for statistics

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 16, 2016 at 03:39:15PM +0000, Frediano Ziglio wrote:
> mmap memory area will remain even if the descriptor is closed.
> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  server/stat-file.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/server/stat-file.c b/server/stat-file.c
> index e9b4208..5f54869 100644
> --- a/server/stat-file.c
> +++ b/server/stat-file.c
> @@ -46,9 +46,11 @@ void stat_file_init(RedStatFile *stat_file, unsigned int max_nodes)
>          spice_error("statistics shm_open failed, %s", strerror(errno));
>      }
>      if (ftruncate(fd, shm_size) == -1) {
> +        close(fd);
>          spice_error("statistics ftruncate failed, %s", strerror(errno));
>      }
>      stat_file->stat = (SpiceStat *)mmap(NULL, shm_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
> +    close(fd);
>      if (stat_file->stat == (SpiceStat *)MAP_FAILED) {
>          spice_error("statistics mmap failed, %s", strerror(errno));
>      }

We never munmap() the mmap data either, dunno if that's intentional?

Christophe

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]