From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gChAb-00085A-KV for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gChAa-00013D-Mw for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53288) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gChAa-00010s-C6 for qemu-devel@nongnu.org; Wed, 17 Oct 2018 04:27:08 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27168368E7 for ; Wed, 17 Oct 2018 08:27:07 +0000 (UTC) From: Markus Armbruster Date: Wed, 17 Oct 2018 10:26:38 +0200 Message-Id: <20181017082702.5581-15-armbru@redhat.com> In-Reply-To: <20181017082702.5581-1-armbru@redhat.com> References: <20181017082702.5581-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v4 14/38] net/socket: Fix invalid socket type error handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jason Wang Calling error_report() in a function that takes an Error ** argument is suspicious. net_socket_fd_init() does that, and then fails without setting an error. Wrong. I didn't analyze how exactly this can break. A caller that reports the error on failure would crash. Broken when commit c37f0bb1d0d (v2.11.0) converted the function to Error. Fix by calling error_setg() instead of error_report(). Fixes: c37f0bb1d0d24e3a6b5f4659bb305913dcb798a6 Cc: Jason Wang Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau --- net/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/socket.c b/net/socket.c index 6917fbcbf5..90ef3517be 100644 --- a/net/socket.c +++ b/net/socket.c @@ -453,8 +453,8 @@ static NetSocketState *net_socket_fd_init(NetClientSt= ate *peer, case SOCK_STREAM: return net_socket_fd_init_stream(peer, model, name, fd, is_conne= cted); default: - error_report("socket type=3D%d for fd=3D%d must be either" - " SOCK_DGRAM or SOCK_STREAM", so_type, fd); + error_setg(errp, "socket type=3D%d for fd=3D%d must be either" + " SOCK_DGRAM or SOCK_STREAM", so_type, fd); closesocket(fd); } return NULL; --=20 2.17.1