Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 841783ACA70 for ; Mon, 6 Jul 2026 16:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.11.138.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783354654; cv=none; b=oiXri0/ZAsE7a45w24dGBV6MLh3y2WruQh5ry+7RvcwxNJOHPbF1VFaU2a3oUq73QxUDVtUYBd1zfZxJHSZMsgAR3yv818H/FxvsSSExoTEReuTYxiUgRprUYHfEKzEr62v+GDwX59o/QqS3YYD7J2VL9zsNGc5Y0i9G06IIvbg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783354654; c=relaxed/simple; bh=qgrGxiTiPp77FSz3b2g3R4AtQSs1trKaa4ZkalIZ9N4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A6QQi5Cbwp+hG6gx/QQcruyu4leUR6VqxR4PzG4VaECnA8SV6ocMhdT5sGGCcZN7ZEGModnWOg/GFG0+bcViVWXX/LNOp/HMQG0b2QC6YII7RKtEgAri2ZZt3hl/ZJY5kQxSEA2JwE/q49a3QC2+NRuWvXuEckZCcVArXOJWkuA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=sntech.de; spf=pass smtp.mailfrom=sntech.de; dkim=pass (2048-bit key) header.d=sntech.de header.i=@sntech.de header.b=cWuBWTK6; arc=none smtp.client-ip=185.11.138.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=sntech.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sntech.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sntech.de header.i=@sntech.de header.b="cWuBWTK6" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sntech.de; s=gloria202408; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type; bh=uqQlAkyUrdzL/P0yTX9G71yGvY+5QSdTjHzrWm+aQ4g=; b=cWuBWTK6ZoeFYrY8Eb9X+VL/8B ETTDVccQqJfIZsyDp7ChIB+N9HtO0p1jkyvyYlMYMqQRVP7ev+4AxvVTfU7849RJ7VUc6Vpr79Ujx dczdSNjVbfsv0MwpuoTqxKLzmqalA9goW+zgusfWv5TAwuwvSG/Hw+l36m3ohn5LklVNPUNDqkFlo PL0KO+VTAuqcHh7qGmSRmV65IVCr/iG1Y7BrAxD4WJ5fEcHVOCr46aXAMg5qvGMSQeRofBaIV8jRb a2Knbw4eopcDWLZC18U5GhGmYFwFWJF6WC6Tgb6rdB5GSDvMro1TX1r9grRGew2DWDw+l2hoMhftI 2o86nXcw==; From: Heiko Stuebner To: stable@vger.kernel.org Cc: heiko@sntech.de, quentin.schulz@cherry.de, Marco Scardovi , Bartosz Golaszewski , Heiko Stuebner Subject: [PATCH 6.12.y 2/3] gpio: rockchip: teardown bugs and resource leaks Date: Mon, 6 Jul 2026 18:17:12 +0200 Message-ID: <20260706161713.2676365-3-heiko@sntech.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260706161713.2676365-1-heiko@sntech.de> References: <20260706161713.2676365-1-heiko@sntech.de> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Marco Scardovi [ Upstream commit 9500077678230e36d22bf16d2b9539c13e59a801 ] Address several teardown issues and resource leaks in the driver's remove path and error handling: 1. Debounce clock reference leak: The debounce clock (bank->db_clk) is obtained using of_clk_get() which increments the clock's reference count, but clk_put() is never called. Register a devm action to cleanly release it on unbind. Note that of_clk_get(..., 1) remains necessary over devm_clk_get() because the DT binding does not define clock-names, precluding name-based lookup. OA 2. Unregistered chained IRQ handler: The chained IRQ handler is not disconnected in remove(). If a stray interrupt fires after the driver is removed, the kernel attempts to execute a stale handler, leading to a panic. Fix this by clearing the handler in remove(). 3. IRQ domain leak: The linear IRQ domain and its generic chips are allocated manually during probe but never removed. Remove the IRQ domain during driver teardown to free the associated generic chips and mappings. Fixes: 936ee2675eee ("gpio/rockchip: add driver for rockchip gpio") Assisted-by: Antigravity:gemini-3.5-flash Signed-off-by: Marco Scardovi Link: https://patch.msgid.link/20260526171050.12785-3-scardracs@disroot.org [Bartosz: don't emit an error message on devres allocation failure] Signed-off-by: Bartosz Golaszewski Signed-off-by: Heiko Stuebner --- drivers/gpio/gpio-rockchip.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index 16c1ec3a5d0e..0a93c74933f0 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -629,10 +629,17 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank) return ret; } +static void rockchip_clk_put(void *data) +{ + struct clk *clk = data; + + clk_put(clk); +} + static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) { struct resource res; - int id = 0; + int id = 0, ret; if (of_address_to_resource(bank->of_node, 0, &res)) { dev_err(bank->dev, "cannot find IO resource for bank\n"); @@ -663,6 +670,11 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) dev_err(bank->dev, "cannot find debounce clk\n"); return -EINVAL; } + + ret = devm_add_action_or_reset(bank->dev, rockchip_clk_put, + bank->db_clk); + if (ret) + return ret; break; case GPIO_TYPE_V1: bank->gpio_regs = &gpio_regs_v1; @@ -779,6 +791,9 @@ static void rockchip_gpio_remove(struct platform_device *pdev) { struct rockchip_pin_bank *bank = platform_get_drvdata(pdev); + irq_set_chained_handler_and_data(bank->irq, NULL, NULL); + if (bank->domain) + irq_domain_remove(bank->domain); gpiochip_remove(&bank->gpio_chip); } -- 2.53.0