aio-posix: avoid NULL pointer dereference in aio_epoll_update
aio_epoll_update dereferences parameter "node", but it could have been NULL if deleting an fd handler that was not registered in the first place. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-id: 20161108135524.25927-2-pbonzini@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
e6af1e0854
commit
36173ec5f1
30
aio-posix.c
30
aio-posix.c
@ -217,21 +217,23 @@ void aio_set_fd_handler(AioContext *ctx,
|
|||||||
|
|
||||||
/* Are we deleting the fd handler? */
|
/* Are we deleting the fd handler? */
|
||||||
if (!io_read && !io_write) {
|
if (!io_read && !io_write) {
|
||||||
if (node) {
|
if (node == NULL) {
|
||||||
g_source_remove_poll(&ctx->source, &node->pfd);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* If the lock is held, just mark the node as deleted */
|
g_source_remove_poll(&ctx->source, &node->pfd);
|
||||||
if (ctx->walking_handlers) {
|
|
||||||
node->deleted = 1;
|
/* If the lock is held, just mark the node as deleted */
|
||||||
node->pfd.revents = 0;
|
if (ctx->walking_handlers) {
|
||||||
} else {
|
node->deleted = 1;
|
||||||
/* Otherwise, delete it for real. We can't just mark it as
|
node->pfd.revents = 0;
|
||||||
* deleted because deleted nodes are only cleaned up after
|
} else {
|
||||||
* releasing the walking_handlers lock.
|
/* Otherwise, delete it for real. We can't just mark it as
|
||||||
*/
|
* deleted because deleted nodes are only cleaned up after
|
||||||
QLIST_REMOVE(node, node);
|
* releasing the walking_handlers lock.
|
||||||
deleted = true;
|
*/
|
||||||
}
|
QLIST_REMOVE(node, node);
|
||||||
|
deleted = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user