Skip to content

Commit b63cffe

Browse files
chenzhijiaGUIDINGLI
authored andcommitted
libs/libc/unistd:Fix errcode not return normally
Exit the program and return errcode when ioctl fail Signed-off-by: chenzhijia <chenzhijia@xiaomi.com>
1 parent d52074a commit b63cffe

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

libs/libc/unistd/lib_crypt_r.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,21 @@ static int md5_init(FAR cryptodev_context_t *ctx)
8080
fd = open("/dev/crypto", O_RDWR, 0);
8181
if (fd < 0)
8282
{
83-
return -errno;
83+
return -get_errno();
8484
}
8585

8686
ret = ioctl(fd, CRIOGET, &ctx->fd);
8787
close(fd);
8888
if (ret < 0)
8989
{
90-
ret = -errno;
90+
return -get_errno();
9191
}
9292

9393
ctx->session.mac = CRYPTO_MD5;
9494
ret = ioctl(ctx->fd, CIOCGSESSION, &ctx->session);
9595
if (ret < 0)
9696
{
97-
return -errno;
97+
return -get_errno();
9898
}
9999

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

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

117117
static int md5_finish(FAR cryptodev_context_t *ctx,
@@ -125,7 +125,7 @@ static int md5_finish(FAR cryptodev_context_t *ctx,
125125
ret = ioctl(ctx->fd, CIOCCRYPT, &ctx->crypt);
126126
if (ret < 0)
127127
{
128-
return -errno;
128+
return -get_errno();
129129
}
130130

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

0 commit comments

Comments
 (0)