[CRIU] [PATCH] unix: handle unlink failure correctly

Andrew Vagin avagin at virtuozzo.com
Wed Jul 20 12:12:16 PDT 2016


On Tue, Jul 19, 2016 at 02:41:42PM +0000, Tycho Andersen wrote:
> Instead of returning, we should revert the cwd as in all the other error
> paths.
> 
> *** CID 164720:  Resource leaks  (RESOURCE_LEAK)
> /criu/sk-unix.c: 1030 in bind_unix_sk()
> 1024                                    goto done;
> 1025                            }
> 1026                    }
> 1027
> 1028                    if (ui->ue->deleted && unlink((char
> *)ui->ue->name.data) < 0) {
> 1029                            pr_perror("failed to unlink %s\n",
> ui->ue->name.data);
> >>>     CID 164720:  Resource leaks  (RESOURCE_LEAK)
> >>>     Handle variable "cwd_fd" going out of scope leaks the handle.
> 1030                            return -1;
> 1031                    }
> 1032            }
> 1033
> 1034            if (ui->ue->state != TCP_LISTEN)
> 1035                    futex_set_and_wake(&ui->prepared, 1);
> 
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> CC: Andrew Vagin <avagin at virtuozzo.com>

Acked-by: Andrew Vagin <avagin at virtuozzo.com>

Thanks!

> ---
>  criu/sk-unix.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/criu/sk-unix.c b/criu/sk-unix.c
> index 9021c9a..2bab17f 100644
> --- a/criu/sk-unix.c
> +++ b/criu/sk-unix.c
> @@ -1027,7 +1027,7 @@ static int bind_unix_sk(int sk, struct unix_sk_info *ui)
>  
>  		if (ui->ue->deleted && unlink((char *)ui->ue->name.data) < 0) {
>  			pr_perror("failed to unlink %s\n", ui->ue->name.data);
> -			return -1;
> +			goto done;
>  		}
>  	}
>  
> -- 
> 2.7.4
> 


More information about the CRIU mailing list