[Ocfs2-tools-devel] [PATCH 4/5] libo2dlm: Close file description after use
Goldwyn Rodrigues
rgoldwyn at suse.de
Fri Apr 24 08:18:16 PDT 2015
On 04/02/2015 07:46 AM, piaojun wrote:
> In o2dlm_generate_random_value(), randfd should be closed after use.
>
> Signed-off-by: Jun Piao <piaojun at huawei.com>
> Reviewed-by: Alex Chen <alex.chen at huawei.com>
Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.com>
>
> ---
> libo2dlm/o2dlm.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libo2dlm/o2dlm.c b/libo2dlm/o2dlm.c
> index dbc642b..375f659 100644
> --- a/libo2dlm/o2dlm.c
> +++ b/libo2dlm/o2dlm.c
> @@ -102,9 +102,10 @@ static errcode_t o2dlm_generate_random_value(int64_t *value)
> if ((randfd = open("/dev/urandom", O_RDONLY)) == -1)
> return O2DLM_ET_RANDOM;
>
> - if (read(randfd, value, readlen) != readlen)
> + if (read(randfd, value, readlen) != readlen) {
> + close(randfd);
> return O2DLM_ET_RANDOM;
> -
> + }
> close(randfd);
>
> return 0;
>
--
Goldwyn
More information about the Ocfs2-tools-devel
mailing list