Skip to content

Commit

Permalink
libs/libc/unistd:Fix errcode not return normally
Browse files Browse the repository at this point in the history
Exit the program and return errcode when ioctl fail

Signed-off-by: chenzhijia <[email protected]>
  • Loading branch information
Cccccczj authored and GUIDINGLI committed Oct 16, 2024
1 parent d52074a commit b63cffe
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libs/libc/unistd/lib_crypt_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,21 @@ static int md5_init(FAR cryptodev_context_t *ctx)
fd = open("/dev/crypto", O_RDWR, 0);
if (fd < 0)
{
return -errno;
return -get_errno();
}

ret = ioctl(fd, CRIOGET, &ctx->fd);
close(fd);
if (ret < 0)
{
ret = -errno;
return -get_errno();
}

ctx->session.mac = CRYPTO_MD5;
ret = ioctl(ctx->fd, CIOCGSESSION, &ctx->session);
if (ret < 0)
{
return -errno;
return -get_errno();
}

ctx->crypt.ses = ctx->session.ses;
Expand All @@ -111,7 +111,7 @@ static int md5_update(FAR cryptodev_context_t *ctx,
ctx->crypt.len = ilen;

ret = ioctl(ctx->fd, CIOCCRYPT, &ctx->crypt);
return ret < 0 ? -errno : ret;
return ret < 0 ? -get_errno() : ret;
}

static int md5_finish(FAR cryptodev_context_t *ctx,
Expand All @@ -125,7 +125,7 @@ static int md5_finish(FAR cryptodev_context_t *ctx,
ret = ioctl(ctx->fd, CIOCCRYPT, &ctx->crypt);
if (ret < 0)
{
return -errno;
return -get_errno();
}

ioctl(ctx->fd, CIOCFSESSION, &ctx->session.ses);
Expand Down

0 comments on commit b63cffe

Please sign in to comment.