diff --git a/net/local/local_recvmsg.c b/net/local/local_recvmsg.c index eb95629383b..14fe7c7041a 100644 --- a/net/local/local_recvmsg.c +++ b/net/local/local_recvmsg.c @@ -177,8 +177,7 @@ static void local_recvctl(FAR struct local_conn_s *conn, { fds[i] = file_dup(peer->lc_cfps[i], 0, flags & MSG_CMSG_CLOEXEC ? O_CLOEXEC : 0); - file_close(peer->lc_cfps[i]); - kmm_free(peer->lc_cfps[i]); + file_put(peer->lc_cfps[i]); peer->lc_cfps[i] = NULL; peer->lc_cfpcount--; if (fds[i] < 0) diff --git a/net/local/local_sendmsg.c b/net/local/local_sendmsg.c index 32539732983..72fe2049c93 100644 --- a/net/local/local_sendmsg.c +++ b/net/local/local_sendmsg.c @@ -65,8 +65,7 @@ static void local_freectl(FAR struct local_conn_s *conn, int count) while (count-- > 0) { - file_close(peer->lc_cfps[--peer->lc_cfpcount]); - kmm_free(peer->lc_cfps[peer->lc_cfpcount]); + file_put(peer->lc_cfps[--peer->lc_cfpcount]); peer->lc_cfps[peer->lc_cfpcount] = NULL; } } @@ -75,7 +74,6 @@ static int local_sendctl(FAR struct local_conn_s *conn, FAR struct msghdr *msg) { FAR struct local_conn_s *peer; - FAR struct file *filep2; FAR struct file *filep; FAR struct cmsghdr *cmsg; int count = 0; @@ -117,23 +115,7 @@ static int local_sendctl(FAR struct local_conn_s *conn, goto fail; } - filep2 = kmm_zalloc(sizeof(*filep2)); - if (!filep2) - { - file_put(filep); - ret = -ENOMEM; - goto fail; - } - - ret = file_dup2(filep, filep2); - file_put(filep); - if (ret < 0) - { - kmm_free(filep2); - goto fail; - } - - peer->lc_cfps[peer->lc_cfpcount++] = filep2; + peer->lc_cfps[peer->lc_cfpcount++] = filep; } }