Skip to content

Commit

Permalink
device: fixes for socket holds and leaking aio data
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gdamore committed Dec 8, 2024
1 parent 45ad63d commit 8af6bef
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/core/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 8af6bef

Please sign in to comment.