From: David Woodhouse Date: Thu, 8 Jul 2021 19:30:38 +0000 (+0100) Subject: Check eventfd read/write returns X-Git-Tag: v8.20~101 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=fd8cfdfd340a7daef61de50e4351128445136134;p=users%2Fdwmw2%2Fopenconnect.git Check eventfd read/write returns A short write should never happen but we get compiler/Coverity complaints if we don't check. Signed-off-by: David Woodhouse --- diff --git a/vhost.c b/vhost.c index 94827675..6032bc2d 100644 --- a/vhost.c +++ b/vhost.c @@ -530,7 +530,11 @@ int vhost_tun_mainloop(struct openconnect_info *vpninfo, int *timeout, int reada if (kick) { barrier(); - write(vpninfo->vhost_kick_fd, &kick, sizeof(kick)); + if (write(vpninfo->vhost_kick_fd, &kick, sizeof(kick)) != sizeof(kick)) { + /* Can never happen */ + vpn_progress(vpninfo, PRG_ERR, + _("Failed to kick vhost-net eventfd\n")); + } vpn_progress(vpninfo, PRG_TRACE, _("Kick vhost ring\n")); did_work = 1; @@ -542,7 +546,11 @@ int vhost_tun_mainloop(struct openconnect_info *vpninfo, int *timeout, int reada * again. */ if (!did_work && readable) { uint64_t evt; - read(vpninfo->vhost_call_fd, &evt, sizeof(evt)); + if (read(vpninfo->vhost_call_fd, &evt, sizeof(evt)) != sizeof(evt)) { + /* Can never happen */ + vpn_progress(vpninfo, PRG_ERR, + _("Failed to read vhost-net call eventfd\n")); + } } /* If we aren't going to have one more turn around the mainloop,