From nobody Fri Apr 14 14:00:47 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PydQ764V0z45JL2; Fri, 14 Apr 2023 14:00:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PydQ74nRdz3JkB; Fri, 14 Apr 2023 14:00:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681480847; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SQzQTCkx4DAdFQ2MmTeew/tBhvdmFGRFdp4hM/Sw/0w=; b=ieuT27mdR7ewPRrA/9MUFeXW1ba3yeovjdsDJJDoZBdgtdWIUdDWW1PMryrF5BdJRs+n2V b8SN+GskdWA2pSRm2E2+eYK/XF5Wu60TSwIQ8B0frsS7jbQyDyjmErVO/ghDuoiSRmgTXO 5kPENeDNAqnsgki/TaUsWmm6w/hVwYO89DbgAtP5o9c70I5oJ08zDOKuv6b0a+7IJnxfxT e1aN5kzr+epPy6oFtiYtOGJyRvDJop3etzzDD8qH71wwU0ehSX4bdqwAiArCfn3gbBGEjR /3PD25e0Lp2hk6S6lJei81Jp+Aa5Ye5kCto+TRTOBDwF9857ExuAuWZ/o7R/ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681480847; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SQzQTCkx4DAdFQ2MmTeew/tBhvdmFGRFdp4hM/Sw/0w=; b=Y6bWiRiXnAz5XLvywh8NQlbmZSvJpjPNf5j/ZLSJ8pUry+C53Jg/HHqZ9sMWY0qYvQDbMa 6myLBCcMn7tc40SJsSSRudsSOltvHVYXMkfw7vjwD6CpucxA3e5aQ9lOfuAEsc7RU11OlY kb/5HTtk2RYxn2oLyo/CipRfWFa08rGoyzGX/Z2OI3/smKFzQIvzVILgLkeY2pIL6Het9d 9dtjUiTCDVSDKKH+EXfI84WEWM6VGxapseYPqZLg4RVIfhLKFv+rVdhGBkiE1R5QuTqbE9 l9vuDw3jgGGtk86HSqqdW8BqpVgV3+HkbyWoEsWCEymBzK2i8RtBHBtvLsS6BQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681480847; a=rsa-sha256; cv=none; b=MqVtuQ8zYU8YSM306PO9z/nWDmITDlKUNn8dD5lsGZZmubC5PAFqlvWhYkg9AHxMKvIV7f lgMBJcPWhrUi25tYEt4SvbwUkbDV48gTVNfMM9U9qYTp0WKZ9nzR6ZXiSwyxhhDNSu0D54 5M7z+26NbfoieiF5WeemUq4tZDmLt+NvIYtjo8Fexu2hAFBYUpPnXVUkfUYjrlyVHEDjxh B6c4HHNJYm0gG+8LhMkU4Kyu56ddZx6DZT6aiXRbGgiDYpxF8Qw7xZw73qPKTa+nc5ITCX guuaZ3zNcnGR1R1BGqDoUVF1+NzfknP4GZjEmNTNLTn21UluCaMjCdlR4gWP+g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PydQ73tMHzRX8; Fri, 14 Apr 2023 14:00:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33EE0li9083565; Fri, 14 Apr 2023 14:00:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33EE0lTl083564; Fri, 14 Apr 2023 14:00:47 GMT (envelope-from git) Date: Fri, 14 Apr 2023 14:00:47 GMT Message-Id: <202304141400.33EE0lTl083564@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Roger=20Pau=20Monn=C3=A9?= Subject: git: 054073c2831c - main - xen/intr: xen_intr_bind_isrc() always set handle List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 054073c2831cf70c3f2937b915663e1e2c75a25d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=054073c2831cf70c3f2937b915663e1e2c75a25d commit 054073c2831cf70c3f2937b915663e1e2c75a25d Author: Elliott Mitchell AuthorDate: 2022-05-14 21:41:51 +0000 Commit: Roger Pau Monné CommitDate: 2023-04-14 13:58:45 +0000 xen/intr: xen_intr_bind_isrc() always set handle Previously the upper layer handle was being set before the last potential error condition. The reasoning appears to have been it was assumed invalid in case of an error being returned. Now ensure it is invalid until just before a successful return. Fixes: 76acc41fb7c7 ("Implement vector callback for PVHVM and unify event channel implementations") Fixes: 6d54cab1fe7d ("xen: allow to register event channels without handlers") Reviewed by: royger --- sys/x86/xen/xen_intr.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/sys/x86/xen/xen_intr.c b/sys/x86/xen/xen_intr.c index 4b9b4675b5a0..167870b892f1 100644 --- a/sys/x86/xen/xen_intr.c +++ b/sys/x86/xen/xen_intr.c @@ -410,7 +410,7 @@ static int xen_intr_bind_isrc(struct xenisrc **isrcp, evtchn_port_t local_port, enum evtchn_type type, const char *intr_owner, driver_filter_t filter, driver_intr_t handler, void *arg, enum intr_type flags, - xen_intr_handle_t *port_handlep) + xen_intr_handle_t *const port_handlep) { struct xenisrc *isrc; int error; @@ -420,6 +420,7 @@ xen_intr_bind_isrc(struct xenisrc **isrcp, evtchn_port_t local_port, printf("%s: %s: Bad event handle\n", intr_owner, __func__); return (EINVAL); } + *port_handlep = NULL; mtx_lock(&xen_intr_isrc_lock); isrc = xen_intr_find_unused_isrc(type); @@ -436,9 +437,6 @@ xen_intr_bind_isrc(struct xenisrc **isrcp, evtchn_port_t local_port, refcount_init(&isrc->xi_refcount, 1); mtx_unlock(&xen_intr_isrc_lock); - /* Assign the opaque handler */ - *port_handlep = xen_intr_handle_from_isrc(isrc); - #ifdef SMP if (type == EVTCHN_TYPE_PORT) { /* @@ -450,23 +448,23 @@ xen_intr_bind_isrc(struct xenisrc **isrcp, evtchn_port_t local_port, } #endif - if (filter == NULL && handler == NULL) { - /* - * No filter/handler provided, leave the event channel - * masked and without a valid handler, the caller is - * in charge of setting that up. - */ - *isrcp = isrc; - return (0); + /* + * If a filter or handler function is provided, add it to the event. + * Otherwise the event channel is left masked and without a handler, + * the caller is in charge of setting that up. + */ + if (filter != NULL || handler != NULL) { + error = xen_intr_add_handler(intr_owner, filter, handler, arg, + flags, xen_intr_handle_from_isrc(isrc)); + if (error != 0) { + xen_intr_release_isrc(isrc); + return (error); + } } - error = xen_intr_add_handler(intr_owner, filter, handler, arg, flags, - *port_handlep); - if (error != 0) { - xen_intr_release_isrc(isrc); - return (error); - } *isrcp = isrc; + /* Assign the opaque handler */ + *port_handlep = xen_intr_handle_from_isrc(isrc); return (0); }