From nobody Thu Jul 17 00:47:52 2025 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 4bjDmS4pxrz62CbS; Thu, 17 Jul 2025 00:47:52 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bjDmS3tBWz3b3S; Thu, 17 Jul 2025 00:47:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752713272; 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=oWgmnflWAu+Sb3A70TPNUUBP4hbvhu4rySBpwqGS2Y8=; b=sbyoMnF2+EzOo71t0BqDi/VKEsvrObWCPvnq+iShQy7vsHwcrg4+1gU46J9tzT22UCjKTh gUCHQfqbXjED6hwOSVje0A6QYxJ1vwhrTo54aG5RBsMw6jqWYMdmeM5IMDSmPmKcmg3RCU +fOhT0LG6/yKTDlKTPwSfI5KoKQ2aCgFG+I9uz7xRYgSX3rxJh21XptraBI3xsJ+KDm6zL odK1Ewvktqx19mfgRn5tehHVq493kArJgdU2LRtIQyt8DLmhWIZFBnoNktjmB1wq1swmUM HIlM/pZy03UNi1bPwpGOdAna9fdRn3uHmjOl1M4rYyi5rWd/a3NMkK/1ED935w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752713272; 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=oWgmnflWAu+Sb3A70TPNUUBP4hbvhu4rySBpwqGS2Y8=; b=JcasmVS9M7gzewJzEXUWcyqEBWII2H5ndJST2ABx1751pU4mWEea7PP1KJ9XCGcE+CfY0s 41KlWN4j2sXJhoU+hHRSuUUeB1bRkDfb/M8ODqFrLnfEJnYXxrDZtdZmW/JuKhBlR31ZKJ cXhBuL51577kZbd6IAXdVgMf+4xiKA/urkTnECNYuXBRV/6P3yBQrW8w2sF3rQ2hZe+Ma0 ype+M9o5tkkef4Tkjoq1ZkFYJfpqzOoxoBLu/NFvSuerAVAYHRX8t20tHtT0/+xmr1w84l ygPXjgE15kO1vutZB8eH9tkz3R7tv5+rfTurdFvfNwzpDRUz8GKsFjHjvG1c1w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1752713272; a=rsa-sha256; cv=none; b=vPxG1wPSWD+ofU7obs/yICWTadmuPdCpCqRG0IzaxZ8WvUMTulZrqtd+3oguAkiVYHudB3 tLpylRpCGJHr6H48oGXCr0eb5dDRYHGEIleZ9wZ9kPJ1HJyHiZDIezQB9lqwN4iCQ/JUcV iGv0C5a1BOEpLJo5VkcT3CUYjJMCwHbRBqmrNohctyIpphH4yqIyqakHuyZCwRr8bJv/Xk IqLd4GGXvx3tvF44qSf1T+c1/oQBeyAgivUe1MfJQxvQXDwYZ+XyRMdrE1GvA85Bij15mQ eEMOIxPwes73IQqxGws3toOqHKnolldY3tS+Wy2noFwj1isbFEbktqwhU0Puhg== 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 4bjDmS3PjQzYtq; Thu, 17 Jul 2025 00:47:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 56H0lq4Z002061; Thu, 17 Jul 2025 00:47:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56H0lqp6002058; Thu, 17 Jul 2025 00:47:52 GMT (envelope-from git) Date: Thu, 17 Jul 2025 00:47:52 GMT Message-Id: <202507170047.56H0lqp6002058@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ahmad Khalifa Subject: git: cc86794b0319 - main - gpiobus: plug IRQ leaks 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vexeduxr X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cc86794b0319bad273a84e8bc36651a141b2ddc7 Auto-Submitted: auto-generated The branch main has been updated by vexeduxr: URL: https://cgit.FreeBSD.org/src/commit/?id=cc86794b0319bad273a84e8bc36651a141b2ddc7 commit cc86794b0319bad273a84e8bc36651a141b2ddc7 Author: Ahmad Khalifa AuthorDate: 2025-07-14 17:47:06 +0000 Commit: Ahmad Khalifa CommitDate: 2025-07-17 00:33:52 +0000 gpiobus: plug IRQ leaks Unmap the IRQ instead of just freeing the map data in the case of an error. Also don't overwrite the resource's virtual address since the copy of the map data made by intr_activate_irq is stored there. Implement gpiobus_release_resource so it can unmap IRQs mapped by gpio_alloc_intr_resource. Reviewed by: imp Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D51325 --- sys/dev/gpio/gpiobus.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/sys/dev/gpio/gpiobus.c b/sys/dev/gpio/gpiobus.c index ab7f13177969..764bcb7e6ee8 100644 --- a/sys/dev/gpio/gpiobus.c +++ b/sys/dev/gpio/gpiobus.c @@ -110,10 +110,9 @@ gpio_alloc_intr_resource(device_t consumer_dev, int *rid, u_int alloc_flags, res = bus_alloc_resource(consumer_dev, SYS_RES_IRQ, rid, irq, irq, 1, alloc_flags); if (res == NULL) { - intr_free_intr_map_data((struct intr_map_data *)gpio_data); + intr_unmap_irq(irq); return (NULL); } - rman_set_virtual(res, gpio_data); return (res); } #else @@ -866,6 +865,25 @@ gpiobus_alloc_resource(device_t bus, device_t child, int type, int *rid, end, count, flags)); } +static int +gpiobus_release_resource(device_t dev, device_t child, struct resource *r) +{ + int err; +#ifdef INTRNG + u_int irq; + + irq = rman_get_start(r); + MPASS(irq == rman_get_end(r)); +#endif + err = bus_generic_rman_release_resource(dev, child, r); + if (err != 0) + return (err); +#ifdef INTRNG + intr_unmap_irq(irq); +#endif + return (0); +} + static struct resource_list * gpiobus_get_resource_list(device_t bus __unused, device_t child) { @@ -1060,7 +1078,7 @@ static device_method_t gpiobus_methods[] = { DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), DEVMETHOD(bus_alloc_resource, gpiobus_alloc_resource), - DEVMETHOD(bus_release_resource, bus_generic_rman_release_resource), + DEVMETHOD(bus_release_resource, gpiobus_release_resource), DEVMETHOD(bus_activate_resource, bus_generic_rman_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_rman_deactivate_resource), DEVMETHOD(bus_get_resource_list, gpiobus_get_resource_list),