[CRIU] [PATCH 1/2] mount: fix uninitialized use of fd on switch_ns error

Andrew Vagin avagin at virtuozzo.com
Wed Jan 31 21:23:55 MSK 2018


Applied, thanks!
On Mon, Jan 29, 2018 at 11:21:07AM +0300, Pavel Tikhomirov wrote:
> close_safe can operate uninitialized fd in case of error in switch_ns,
> found by Coverity Scan:
> 
> *** CID 187164:  Uninitialized variables  (UNINIT)
> /criu/mount.c: 1313 in open_mountpoint()
> 1307     err:
> 1308            return 1;
> 1309     }
> 1310
> 1311     int open_mountpoint(struct mount_info *pm)
> 1312     {
> >>>     CID 187164:  Uninitialized variables  (UNINIT)
> >>>     Declaring variable "fd" without initializer.
> 1313            int fd, cwd_fd, ns_old = -1;
> 1314
> 1315            /* No overmounts and children - the entire mount is visible */
> 1316            if (list_empty(&pm->children) && !mnt_is_overmounted(pm))
> 1317                    return __open_mountpoint(pm, -1);
> 1318
> 
> Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
> ---
>  criu/mount.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/criu/mount.c b/criu/mount.c
> index aac5c0033..a62c1c6ac 100644
> --- a/criu/mount.c
> +++ b/criu/mount.c
> @@ -1310,7 +1310,7 @@ int ns_open_mountpoint(void *arg)
>  
>  int open_mountpoint(struct mount_info *pm)
>  {
> -	int fd, cwd_fd, ns_old = -1;
> +	int fd = -1, cwd_fd, ns_old = -1;
>  
>  	/* No overmounts and children - the entire mount is visible */
>  	if (list_empty(&pm->children) && !mnt_is_overmounted(pm))
> -- 
> 2.14.3
> 


More information about the CRIU mailing list