From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 20C383218C0; Mon, 18 Aug 2025 12:57:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755521829; cv=none; b=LVo7P6h1uUDAEZ3EU1Z8AWKPJ42m7BO908WTml47gzvNh81mh89vXs6Rp3BJbf8o3WWrIGn5TKCIqFhO2Zk2/j1kQq0WCyva/36E8iDpen1J1FHT94zhs+GP4Ud/4AVmWe+waOO9hIFdx7QBg86AbIybHhkveZU1IK6rDwqSoE8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755521829; c=relaxed/simple; bh=8HQuoiyIu7APNA9pulGXufujRBa++bXEghZ3G9+34iQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cTaHMZ0hol+WHTiUA+pMn+tkIzpG1BoNukRrmrrXC4vZQMRYfViVS+R8+sHo7SMG61dNdDJ2o4nNrpXorkn22WDW2m+HMZSwJtC+h9Xbnk3bg0sdaKvi0/o9MwTxqmIyHWfNK+HT++QVFlsxjtA73ZTiEFjXO8n493evBJeg39Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=P/G8soO5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="P/G8soO5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80D49C4CEEB; Mon, 18 Aug 2025 12:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1755521829; bh=8HQuoiyIu7APNA9pulGXufujRBa++bXEghZ3G9+34iQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P/G8soO5Hpg/hKPYIeVTYZFnyX4YE3bMYbirIOhLwhJ/D4iEJH7EmJ9fFRZn7YM2X oa/rEBunOYWdZh/29UJbKojQd2JLGeTfduJDbiNspFt8swASSOxLV7nKmAgBW1eyXj dYpMJzsQbX0AFK3bhj/zLAgSfCiKebltEAFbY8k0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eliav Farber , Sasha Levin Subject: [PATCH 6.12 134/444] pps: clients: gpio: fix interrupt handling order in remove path Date: Mon, 18 Aug 2025 14:42:40 +0200 Message-ID: <20250818124453.937580095@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250818124448.879659024@linuxfoundation.org> References: <20250818124448.879659024@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eliav Farber [ Upstream commit 6bca1e955830808dc90e0506b2951b4256b81bbb ] The interrupt handler in pps_gpio_probe() is registered after calling pps_register_source() using devm_request_irq(). However, in the corresponding remove function, pps_unregister_source() is called before the IRQ is freed, since devm-managed resources are released after the remove function completes. This creates a potential race condition where an interrupt may occur after the PPS source is unregistered but before the handler is removed, possibly leading to a kernel panic. To prevent this, switch from devm-managed IRQ registration to manual management by using request_irq() and calling free_irq() explicitly in the remove path before unregistering the PPS source. This ensures the interrupt handler is safely removed before deactivating the PPS source. Signed-off-by: Eliav Farber Link: https://lore.kernel.org/r/20250527053355.37185-1-farbere@amazon.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/pps/clients/pps-gpio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c index 93e662912b53..1412f8af15f2 100644 --- a/drivers/pps/clients/pps-gpio.c +++ b/drivers/pps/clients/pps-gpio.c @@ -206,8 +206,8 @@ static int pps_gpio_probe(struct platform_device *pdev) } /* register IRQ interrupt handler */ - ret = devm_request_irq(dev, data->irq, pps_gpio_irq_handler, - get_irqf_trigger_flags(data), data->info.name, data); + ret = request_irq(data->irq, pps_gpio_irq_handler, + get_irqf_trigger_flags(data), data->info.name, data); if (ret) { pps_unregister_source(data->pps); dev_err(dev, "failed to acquire IRQ %d\n", data->irq); @@ -224,6 +224,7 @@ static void pps_gpio_remove(struct platform_device *pdev) { struct pps_gpio_device_data *data = platform_get_drvdata(pdev); + free_irq(data->irq, data); pps_unregister_source(data->pps); del_timer_sync(&data->echo_timer); /* reset echo pin in any case */ -- 2.39.5