[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] libvchan: handle libxc evtchn failures properly in init functions
commit f2f06a2f1b42d27dccf08d8ff887c96608b8c6b7 Author: Matthew Daley <mattjd@xxxxxxxxx> AuthorDate: Thu Oct 31 16:41:32 2013 +1300 Commit: Ian Campbell <ian.campbell@xxxxxxxxxx> CommitDate: Thu Oct 31 21:55:53 2013 +0000 libvchan: handle libxc evtchn failures properly in init functions The reasoning behind this patch is that ctrl->event_port is a uint32_t (ie. unsigned), so the current checks on it for negative error results, non-negative port presence etc. are incorrect. Fix by using evtchn_port_or_error_t in the init functions instead, adjusting the error handling, and removing the now-unnecessary check from the close function. Coverity-ID: 1055609 Coverity-ID: 1055610 Coverity-ID: 1055611 Signed-off-by: Matthew Daley <mattjd@xxxxxxxxx> Reviewed-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> --- tools/libvchan/init.c | 47 +++++++++++++++++++++++++++++++++++++++-------- tools/libvchan/io.c | 2 +- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/tools/libvchan/init.c b/tools/libvchan/init.c index 0c7cff6..c080a1c 100644 --- a/tools/libvchan/init.c +++ b/tools/libvchan/init.c @@ -215,15 +215,30 @@ static int init_gnt_cli(struct libxenvchan *ctrl, int domain, uint32_t ring_ref) static int init_evt_srv(struct libxenvchan *ctrl, int domain, xentoollog_logger *logger) { + evtchn_port_or_error_t port; + ctrl->event = xc_evtchn_open(logger, 0); if (!ctrl->event) return -1; - ctrl->event_port = xc_evtchn_bind_unbound_port(ctrl->event, domain); - if (ctrl->event_port < 0) - return -1; + + port = xc_evtchn_bind_unbound_port(ctrl->event, domain); + if (port < 0) + goto fail; + ctrl->event_port = port; + if (xc_evtchn_unmask(ctrl->event, ctrl->event_port)) - return -1; + goto fail; + return 0; + +fail: + if (port >= 0) + xc_evtchn_unbind(ctrl->event, port); + + xc_evtchn_close(ctrl->event); + ctrl->event = NULL; + + return -1; } static int init_xs_srv(struct libxenvchan *ctrl, int domain, const char* xs_base, int ring_ref) @@ -330,15 +345,31 @@ out: static int init_evt_cli(struct libxenvchan *ctrl, int domain, xentoollog_logger *logger) { + evtchn_port_or_error_t port; + ctrl->event = xc_evtchn_open(logger, 0); if (!ctrl->event) return -1; - ctrl->event_port = xc_evtchn_bind_interdomain(ctrl->event, + + port = xc_evtchn_bind_interdomain(ctrl->event, domain, ctrl->event_port); - if (ctrl->event_port < 0) - return -1; - xc_evtchn_unmask(ctrl->event, ctrl->event_port); + if (port < 0) + goto fail; + ctrl->event_port = port; + + if (xc_evtchn_unmask(ctrl->event, ctrl->event_port)) + goto fail; + return 0; + +fail: + if (port >= 0) + xc_evtchn_unbind(ctrl->event, port); + + xc_evtchn_close(ctrl->event); + ctrl->event = NULL; + + return -1; } diff --git a/tools/libvchan/io.c b/tools/libvchan/io.c index 3c8d236..2383364 100644 --- a/tools/libvchan/io.c +++ b/tools/libvchan/io.c @@ -337,7 +337,7 @@ void libxenvchan_close(struct libxenvchan *ctrl) } } if (ctrl->event) { - if (ctrl->event_port >= 0 && ctrl->ring) + if (ctrl->ring) xc_evtchn_notify(ctrl->event, ctrl->event_port); xc_evtchn_close(ctrl->event); } -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |