casaroli commented on code in PR #21106:
URL: https://github.com/apache/nuttx/pull/21106#discussion_r4415814623


##########
libs/libc/unistd/lib_crypt_r.c:
##########
@@ -71,67 +74,89 @@ static FAR char *md5_to64(FAR char *s, unsigned long v, int 
n)
   return s;
 }
 
-static int md5_init(FAR cryptodev_context_t *ctx)
+/* A failed step keeps its error in ctx->error: the later steps do nothing,
+ * and md5_finish() returns the error after it closes the session.
+ */
+
+static void md5_init(FAR cryptodev_context_t *ctx)
 {
-  int ret;
   int fd;
 
   memset(ctx, 0, sizeof(cryptodev_context_t));
+  ctx->fd = -1;

Review Comment:
   `/dev/crypto` handles only CRIOGET (crypto/cryptodev.c:1061); the session 
ioctls go to the descriptor that CRIOGET returns. CRIOGET writes that 
descriptor into `ctx->fd`, so the descriptor of `open()` needs its own variable 
to be closed: with `ctx->fd = open(...)`, it would leak.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to