From: Daniel De Graaf <dgdegra@tycho.nsa.gov>
To: Matthew Daley <mattjd@gmail.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH 24/29] libvchan: handle libxc evtchn failures properly in init functions
Date: Wed, 30 Oct 2013 10:52:38 -0400 [thread overview]
Message-ID: <52711D36.5020709@tycho.nsa.gov> (raw)
In-Reply-To: <CA+nUz_KZ3GQPv8yDYOxAB6-33kGqW=W1f7V1MDYOfUDiSaZnew@mail.gmail.com>
On 10/30/2013 06:12 AM, Matthew Daley wrote:
> On Wed, Oct 30, 2013 at 8:52 PM, Matthew Daley <mattjd@gmail.com> wrote:
>> Also, remove now-unnecessary check from close function.
>>
>> Coverity-ID: 1055609
>> Coverity-ID: 1055610
>> Coverity-ID: 1055611
>> Signed-off-by: Matthew Daley <mattjd@gmail.com>
>
> I should clarify: the base reason for 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.
>
> I can spin a v2 with this mentioned if desired.
>
> - Matthew
I agree the clarification would be useful in the commit message. If you're
spinning a v2, you may want to use evtchn_port_or_error_t in place of int
since that is the actual typedef used in the return.
Either way,
Reviewed-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
>
>> ---
>> 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..314b1f6 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)
>> {
>> + int 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)
>> {
>> + int 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);
>> }
>> --
>> 1.7.10.4
>>
>
--
Daniel De Graaf
National Security Agency
next prev parent reply other threads:[~2013-10-30 14:52 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-30 7:51 Fixes for various minor Coverity issues, volume 3 Matthew Daley
2013-10-30 7:51 ` [PATCH 01/29] libxc: check for xc_domain_get_guest_width failure and pass it down Matthew Daley
2013-10-31 21:03 ` Ian Campbell
2013-11-01 0:24 ` [PATCH v2] " Matthew Daley
2013-11-01 13:12 ` Ian Campbell
2013-11-02 22:57 ` [PATCH v3] libxc: check for various libxc failures and pass them down Matthew Daley
2013-11-02 23:08 ` [PATCH v4] " Matthew Daley
2013-11-04 17:31 ` Ian Campbell
2013-11-05 4:58 ` Matthew Daley
2013-11-05 10:10 ` Ian Campbell
2013-10-30 7:51 ` [PATCH 02/29] libxc: fix retrieval of and remove pointless check on gzip size Matthew Daley
2013-10-30 10:50 ` Andrew Cooper
2013-10-30 22:08 ` Matthew Daley
2013-10-31 2:58 ` [PATCH v2] " Matthew Daley
2013-10-31 10:22 ` Andrew Cooper
2013-10-31 22:07 ` Ian Campbell
2013-10-30 7:51 ` [PATCH 03/29] libxc: fix memory leak in move_l3_below_4G error handling Matthew Daley
2013-10-30 7:51 ` [PATCH 04/29] libxc: don't ignore fd read failures when restoring a domain Matthew Daley
2013-10-30 7:51 ` [PATCH 05/29] libxc: tidy up loop construct in write_compressed Matthew Daley
2013-10-30 7:51 ` [PATCH 06/29] libxc: don't read uninitialized size value in xc_read_image Matthew Daley
2013-10-31 21:22 ` Ian Campbell
2013-10-31 22:12 ` Matthew Daley
2013-10-31 22:26 ` Ian Campbell
2013-10-30 7:51 ` [PATCH 07/29] libxc: remove pointless null pointer check in xc_interface_open_common Matthew Daley
2013-10-30 7:51 ` [PATCH 08/29] libxc: check for xc_domain_get_guest_width failure in xc_domain_resume_any Matthew Daley
2013-10-30 7:51 ` [PATCH 09/29] libxc: check for xc_vcpu_setcontext " Matthew Daley
2013-10-31 21:56 ` Ian Campbell
2013-11-01 0:27 ` [PATCH v2] " Matthew Daley
2013-11-01 13:26 ` Ian Campbell
2013-11-01 16:34 ` [PATCH 09/29] " Ian Jackson
2013-11-04 10:29 ` Ian Campbell
2013-10-30 7:51 ` [PATCH 10/29] libxc: initalize stdio loggers' progress_last_percent values to 0 Matthew Daley
2013-10-30 7:51 ` [PATCH 11/29] libxc: remove null pointer checks in xc_pm_get_{c, p}xstat Matthew Daley
2013-10-30 7:51 ` [PATCH 12/29] libxl: check for transaction abortion failure in libxl_set_memory_target Matthew Daley
2013-10-30 7:51 ` [PATCH 13/29] libxl: check for xc_domain_max_vcpus failure in libxl__build_pre Matthew Daley
2013-10-31 21:29 ` Ian Campbell
2013-11-01 0:29 ` [PATCH v2] " Matthew Daley
2013-11-01 13:27 ` Ian Campbell
2013-10-30 7:51 ` [PATCH 14/29] libxl: don't leak xs_read results in libxl__device_nic_from_xs_be Matthew Daley
2013-10-30 8:58 ` Roger Pau Monné
2013-10-30 9:51 ` Matthew Daley
2013-10-31 21:31 ` Ian Campbell
2013-10-30 7:51 ` [PATCH 15/29] libxl: correct file open success check in libxl__device_pci_reset Matthew Daley
2013-10-30 7:51 ` [PATCH 16/29] libxl: check for xc_domain_shutdown failure in libxl__domain_suspend_common_callback Matthew Daley
2013-10-31 21:36 ` Ian Campbell
2013-11-01 0:30 ` [PATCH v2] " Matthew Daley
2013-11-01 13:27 ` Ian Campbell
2013-10-30 7:51 ` [PATCH 17/29] libxl: don't leak memory in libxl__poller_get failure case Matthew Daley
2013-10-30 7:51 ` [PATCH 18/29] libxl: only close fds which successfully opened in libxl__spawn_local_dm Matthew Daley
2013-10-30 7:51 ` [PATCH 19/29] xl: libxl_list_vm returns a pointer, not a handle Matthew Daley
2013-10-30 7:51 ` [PATCH 20/29] xl: check for restore file open failure in create_domain Matthew Daley
2013-10-30 7:51 ` [PATCH 21/29] xl: remove needless infinite-loop construct " Matthew Daley
2013-10-30 7:51 ` [PATCH 22/29] xl: correct references to long-removed function in error messages Matthew Daley
2013-10-30 7:51 ` [PATCH 23/29] docs: make `xl vcpu-list` example use verbatim formatting Matthew Daley
2013-10-30 10:53 ` Matthew Daley
2013-10-31 3:02 ` [PATCH v2] docs: make `xl vm-list` " Matthew Daley
2013-10-30 7:52 ` [PATCH 24/29] libvchan: handle libxc evtchn failures properly in init functions Matthew Daley
2013-10-30 10:12 ` Matthew Daley
2013-10-30 14:52 ` Daniel De Graaf [this message]
2013-10-30 22:07 ` Matthew Daley
2013-10-30 22:17 ` Matthew Daley
2013-10-31 3:41 ` [PATCH v2] " Matthew Daley
2013-10-30 7:52 ` [PATCH 25/29] libvchan: check for fcntl failures in select-type sample application Matthew Daley
2013-10-30 17:06 ` Daniel De Graaf
2013-10-30 17:13 ` Andrew Cooper
2013-10-30 22:04 ` Matthew Daley
2013-10-31 3:44 ` [PATCH v2] libvchan: tidy up usages of fcntl " Matthew Daley
2013-10-31 21:47 ` Ian Campbell
2013-11-01 0:33 ` [PATCH v3] " Matthew Daley
2013-11-01 13:28 ` Ian Campbell
2013-11-01 14:11 ` Daniel De Graaf
2013-11-04 17:51 ` Ian Campbell
2013-10-30 7:52 ` [PATCH 26/29] xenctx: only alloc symbol if we are inserting it into the symbol table Matthew Daley
2013-10-30 8:59 ` Jan Beulich
2013-10-30 7:52 ` [PATCH 27/29] xenctx: correct error check when opening libxc Matthew Daley
2013-10-30 12:48 ` George Dunlap
2013-10-30 7:52 ` [PATCH 28/29] xentrace: don't try to close null libxc handle in disable_tbufs Matthew Daley
2013-10-30 12:47 ` George Dunlap
2013-10-30 7:52 ` [PATCH 29/29] xentrace: undeadify invalid option argument handling Matthew Daley
2013-10-30 12:47 ` George Dunlap
2013-10-31 12:28 ` Fixes for various minor Coverity issues, volume 3 Andrew Cooper
2013-10-31 21:55 ` Matthew Daley
2013-10-31 22:10 ` Ian Campbell
2013-11-01 2:08 ` Matthew Daley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52711D36.5020709@tycho.nsa.gov \
--to=dgdegra@tycho.nsa.gov \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=mattjd@gmail.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.