aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-12-07 18:55:13 -0800
committerGarrett D'Amore <garrett@damore.org>2024-12-07 18:55:13 -0800
commit8af6befd3a3805501e5c13612558241e60b349ba (patch)
tree3f1585eaa5b68a187c7b11b465b64348578cd3f5 /src/core
parent45ad63d265261203155c882ec93b80a604e9ab3b (diff)
downloadnng-8af6befd3a3805501e5c13612558241e60b349ba.tar.gz
nng-8af6befd3a3805501e5c13612558241e60b349ba.tar.bz2
nng-8af6befd3a3805501e5c13612558241e60b349ba.zip
device: fixes for socket holds and leaking aio data
The aio structures need to be finalized, and the sockets should be held until the device is totally finalized to prevent any possible use after free.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/device.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/core/device.c b/src/core/device.c
index 7a6fb479..815fafcc 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -51,6 +51,11 @@ device_fini(void *arg)
for (int i = 0; i < d->num_paths; i++) {
nni_aio_stop(&d->paths[i].aio);
}
+ for (int i = 0; i < d->num_paths; i++) {
+ nni_aio_fini(&d->paths[i].aio);
+ }
+ nni_sock_rele(d->paths[0].src);
+ nni_sock_rele(d->paths[0].dst);
NNI_FREE_STRUCT(d);
}
@@ -97,8 +102,6 @@ device_cb(void *arg)
nni_aio_finish_error(d->user, d->rv);
d->user = NULL;
}
- nni_sock_rele(d->paths[0].src);
- nni_sock_rele(d->paths[0].dst);
nni_reap(&device_reap, d);
}