From patchwork Mon Aug 14 09:36:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 135304 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2639454vqi; Mon, 14 Aug 2023 03:10:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2dmvWL6cZavExfsGDfX+fG7VUUkOce5PgU7g5uqa1NzaBdlFFFZlhMyQ7N93FxAe8yo3p X-Received: by 2002:a05:6a20:1589:b0:13d:1f99:42f6 with SMTP id h9-20020a056a20158900b0013d1f9942f6mr9815753pzj.6.1692007821674; Mon, 14 Aug 2023 03:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692007821; cv=none; d=google.com; s=arc-20160816; b=sc+oxf1WduOiljHTc+9M4qij+CroHoVPyJFPjQlj9QbIT7KKqUhpUGfeQPo7jTTZix yT8Xj5jEOYrvg8t1wvilPfEAQmdu5PAWCXoD1Fb0MPPZYErpY9yfEvr/8EZVidf71fEy ueHUYFkM5jZ51OlfugyLw0xKOsFrGjMFzeGfVtpFOUGdBSfNc30YW3HNFBPOvrWjbzl0 l0JhA7PUC7CYIbUDOFSszaAWK7023XeFFZw0sfZZX57FrWhcbHFiKw7dke0ZHQY9ie57 7A3UVuFTxWb+V0vzZAOwXG2YpEp4d76jOJTMRqVm7j59Z5gJi+GIMxomdiNYuMVfkJHb +Img== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AOycXFd04D023OSn4+z5Wjq2kon8lZE9bJtSlqr368g=; fh=5VnmXmoZBR4+6qVIfQDiLcsiW+SDqIu0KJ6MYk3TKH8=; b=CGsxNQKnBORGBOBdMtfU4hStjdpDeVOYickIbyHzbF2KLUcqPF4XljnJFU6BtPUbe1 hQmQZMIjeerpHsOf8p+bb3rsWZ5N7CNfF19156Ih/7dHIaHBgUGIX6UqjBjORpaRfs8G eyF4NYXSreJweAWOnCZKMQWBwVA0fQIi0Ftkt1ekDK1HA+qXSbvymvXHFRYZfX6uf0fz IAluWBXCHVhw9optpflnuEcCICckUEPCZiniPlebarG+oibPXITISST3Nn9ML+gn2E/O IvDN3oDSVrHdZZkB1cPxLvod5YhuAKHtsCdvaf6u5EwPgcYfm8tLzzs67BbUfbSgRcqI nvaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=yEAPLYgI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l10-20020a170903244a00b001bde8c9800esi1199633pls.459.2023.08.14.03.10.07; Mon, 14 Aug 2023 03:10:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=yEAPLYgI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234016AbjHNJhH (ORCPT + 99 others); Mon, 14 Aug 2023 05:37:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234541AbjHNJgq (ORCPT ); Mon, 14 Aug 2023 05:36:46 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B839CE62 for ; Mon, 14 Aug 2023 02:36:28 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-31781e15a0cso3640630f8f.3 for ; Mon, 14 Aug 2023 02:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20221208.gappssmtp.com; s=20221208; t=1692005787; x=1692610587; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AOycXFd04D023OSn4+z5Wjq2kon8lZE9bJtSlqr368g=; b=yEAPLYgIWyopvhSbUln0QMRDhSY1QZPCVDzv7XKCmhkJXptR/csHkTQ5sKLcrdeJUo u0fG3zvbMuMI/gQ9C7hGHaUqVc/CeoOS1OY8KKinWbMV+46ynQFTSuxhoXFQ6jDBpzds scZtJmyFSHgzw9vl8iy37xwleG22WMEmayoklPOahCC7aj7dmmxB0vv4HJGi6qNwtEFL dIi58P9rqoUPxq7dMwpry4/kLIDaxKV4ooD/VXe7zU74FaccmLD1LBiHj9ttVSWH5jbp gOOvp80W2moUFlAdKtAUaMxkyQNLqHCu9LCPNF+zdikRNVWcru8D1t/g6WyDzpxKHCIN /iqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692005787; x=1692610587; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AOycXFd04D023OSn4+z5Wjq2kon8lZE9bJtSlqr368g=; b=k9f3isMo9CecSihqCj9XPTcORcbkeWqup4q8fAUKNu158u39kjiW9OMI7gpWqYH/ks xD+T9i5aBytC0x0aZdjVFrQN9WdK1pLmwOjVHwO6WJJfo4kDsanXoGVtG0BDPZ/uAULY YgGFkoxHuwFmyaHiiq4K1oU85gaN3MnZbFkOsoYAGs3EuapURQ9wR0tsST1v13cIfKaX XgLD+M94sxkI5TfhKaULHhpKPgdUHaPAvvDuYaofAtnjkV2y1T/XQ4BgQ5P20PnAOEsD p/1q+GEfUfsVCPXCsv1II/Ouf9IExjKFy/rn7fZMR5qkE4NMTR+j6MthYfuFZPkdiyy6 0KVg== X-Gm-Message-State: AOJu0YzjsKvrzwkBt8YkVK2CKNhZVo3lF9qK0KQhO61vrqvKmts994kj lsaTxbj0r6tELsrvRc76xcp2nfO7hZBN3de0kOU/pw== X-Received: by 2002:adf:f3c6:0:b0:319:6b4a:23aa with SMTP id g6-20020adff3c6000000b003196b4a23aamr4198919wrp.65.1692005787114; Mon, 14 Aug 2023 02:36:27 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d0cb:d23e:f2fb:62b4]) by smtp.gmail.com with ESMTPSA id d17-20020adfe851000000b003197839d68asm2422140wrn.97.2023.08.14.02.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 02:36:26 -0700 (PDT) From: Bartosz Golaszewski To: Thomas Gleixner , Marc Zyngier Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 1/2] genirq: proc: drop unused argument from unregister_handler_proc() Date: Mon, 14 Aug 2023 11:36:20 +0200 Message-Id: <20230814093621.23209-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230814093621.23209-1-brgl@bgdev.pl> References: <20230814093621.23209-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774198793252027749 X-GMAIL-MSGID: 1774198793252027749 From: Bartosz Golaszewski The irq argument is unused. Drop it. Signed-off-by: Bartosz Golaszewski --- kernel/irq/internals.h | 5 ++--- kernel/irq/manage.c | 6 +++--- kernel/irq/proc.c | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h index bdd35bb9c735..eee0e27e6750 100644 --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h @@ -125,14 +125,13 @@ void __irq_wake_thread(struct irq_desc *desc, struct irqaction *action); extern void register_irq_proc(unsigned int irq, struct irq_desc *desc); extern void unregister_irq_proc(unsigned int irq, struct irq_desc *desc); extern void register_handler_proc(unsigned int irq, struct irqaction *action); -extern void unregister_handler_proc(unsigned int irq, struct irqaction *action); +extern void unregister_handler_proc(struct irqaction *action); #else static inline void register_irq_proc(unsigned int irq, struct irq_desc *desc) { } static inline void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) { } static inline void register_handler_proc(unsigned int irq, struct irqaction *action) { } -static inline void unregister_handler_proc(unsigned int irq, - struct irqaction *action) { } +static inline void unregister_handler_proc(struct irqaction *action) { } #endif extern bool irq_can_set_affinity_usr(unsigned int irq); diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index d2742af0f0fd..7ed8a151ded8 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1937,7 +1937,7 @@ static struct irqaction *__free_irq(struct irq_desc *desc, void *dev_id) */ chip_bus_sync_unlock(desc); - unregister_handler_proc(irq, action); + unregister_handler_proc(action); /* * Make sure it's not being used on another CPU and if the chip @@ -2056,7 +2056,7 @@ static const void *__cleanup_nmi(unsigned int irq, struct irq_desc *desc) if (!WARN_ON(desc->action == NULL)) { irq_pm_remove_action(desc, desc->action); devname = desc->action->name; - unregister_handler_proc(irq, desc->action); + unregister_handler_proc(desc->action); kfree(desc->action); desc->action = NULL; @@ -2487,7 +2487,7 @@ static struct irqaction *__free_percpu_irq(unsigned int irq, void __percpu *dev_ raw_spin_unlock_irqrestore(&desc->lock, flags); - unregister_handler_proc(irq, action); + unregister_handler_proc(action); irq_chip_pm_put(&desc->irq_data); module_put(desc->owner); diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index 623b8136e9af..83ed403991c6 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -414,7 +414,7 @@ void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) #undef MAX_NAMELEN -void unregister_handler_proc(unsigned int irq, struct irqaction *action) +void unregister_handler_proc(struct irqaction *action) { proc_remove(action->dir); } From patchwork Mon Aug 14 09:36:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 135303 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2639369vqi; Mon, 14 Aug 2023 03:10:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjM2piY/+95jzwhm73cmlFO++6A5GQJgQkiGDLSNci5V2w1mfjzlMX9DA1XjoPaP85DLIJ X-Received: by 2002:a05:6a00:1ad1:b0:687:6288:783d with SMTP id f17-20020a056a001ad100b006876288783dmr9581962pfv.7.1692007812185; Mon, 14 Aug 2023 03:10:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692007812; cv=none; d=google.com; s=arc-20160816; b=pPX2ItvO/yyBmyuCpdkgyc3HcmhEXcKnzKh7KxKQ3XqiwSe6PL6HvFmh/aHL7Mdo1k 6vBUyrrZTF962FrXReKYK/COqrpXCLFzX5n1/BXzHjxlzRC/w9y/AKjCcjUfMpzGT8BB Bf/Fo/SuYmRpRqAYmkQgACTiDhwnKQh7lYUzJNc8dnHrr8y2ColBt2EZPGP9F202vRjR iu9A3G3FUzeEVFZjlPTTl9MQZc/DjvR2TAqUKH9zQM4+VjjEGR3l/KOyibfts/qUTPt0 7NcBwBuyJ3Taq3qp53TSW3y2m58CwvGPo0sWJpz8KSzYXFv+4nNWxEua7SFVUikY1Kb9 oJ9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=x9GIkI+02jFm9GaovqHGnU7H+AqY3jsX4KEby4kRqP0=; fh=5VnmXmoZBR4+6qVIfQDiLcsiW+SDqIu0KJ6MYk3TKH8=; b=z8+wh4V/lI2I5FF6xTPavaIVPv8lprY046T6gr1xg0KruBdrtNQ8K8PedXTI5D4gFw 3TXYWRiAVWQ8C5zVf+yQcKJpSlJo643IMFWzKkeC8IwsKptDhYsybZ+mFZP4ZxiZYl9v Cs92IPIstMxwFC2toPIk/iFcvEfFcI+9/5AxaaIxz6QTXEt/ULZRK7RgAFSGDOPkRMxq 166aJcfjsgNcQ7uIBB7PR7qpeLSmr+l8XgB/hU1zZ/Aqlar5naOrCAph06jKiY/a6XXn buxnSJqum+Cs4M5qvWekOD8VU1CHofbmesu9GBs7ZwRrAKx3l8RoR26U1gQbugR7RZ/j n83A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=uitaqFVv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a056a0010c400b00686da99493bsi8181123pfu.221.2023.08.14.03.09.58; Mon, 14 Aug 2023 03:10:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=uitaqFVv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234870AbjHNJhD (ORCPT + 99 others); Mon, 14 Aug 2023 05:37:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234699AbjHNJgq (ORCPT ); Mon, 14 Aug 2023 05:36:46 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E0E2E73 for ; Mon, 14 Aug 2023 02:36:29 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fe2048c910so37656665e9.1 for ; Mon, 14 Aug 2023 02:36:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20221208.gappssmtp.com; s=20221208; t=1692005788; x=1692610588; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x9GIkI+02jFm9GaovqHGnU7H+AqY3jsX4KEby4kRqP0=; b=uitaqFVvR6wG+2WZxZnkMJsbIyf80+jIPR57rXBxpxxKezVlMzJKTeUBYqcHrfaKlO hrp7aqI4YGAn8CplW3KnRMOYvF/HPhiP+ar40CrfhJrKkBOjD5jjozVwn5GvtfmZmra8 +jsuiDnH//FbniWJ0t5T8gOYrPGZC4L43txWOhyP6azrObVGJ7n2KsXvfZqGY46CPBjk 9ODpZZejIlfw9nq6gj1CG1oHAWUtAcj6hTOaZrZgvCVmdwiB0H70LwcApl+a1DHwGXmY GB7hp0lceP+YVqEbga7HVcupnwQjyha4U0713nOcu2uf7hPGZKH1lT5Dll/XwMtfa2AW e+9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692005788; x=1692610588; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x9GIkI+02jFm9GaovqHGnU7H+AqY3jsX4KEby4kRqP0=; b=isPFth6x4mbjCK/YNinKaptx0XJu+Db41qmauxE2rxjG1Lln6khfXskDwpYBxw8fzw 9pBSkUJVMokgAIKK5jwTX8UZuWyMCiwLcAjtDqTurvOlII9Q/Ti11cr5vsshnTlb/JsA gkFnpZh97qhTKtI552UckbV80kHrdVmHHSOdM+UUZ6PYSayqhAct0NwJV60VErT4o6vC 6Xobi6T9TI+N+3iSB6JGIPrj5AzEd7E9MHYLrHcORiZ30Yk32pj2ghfnQIic+nkomv1s nzspttHvEy1lunVC8anRiRSVr+pqHNkj8/P9Wjedd/IKlzSHHPea0DrukxGESiK6KsDk qpgQ== X-Gm-Message-State: AOJu0YygtAIFaT7HNSieMVJlQGMXl0rAGKnVbmcBuew2Vuyr0lg31UQc SQv2RuDy/6I88h1iO1E0INiv7Q== X-Received: by 2002:adf:ff92:0:b0:317:ed01:dc48 with SMTP id j18-20020adfff92000000b00317ed01dc48mr6349175wrr.9.1692005788084; Mon, 14 Aug 2023 02:36:28 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d0cb:d23e:f2fb:62b4]) by smtp.gmail.com with ESMTPSA id d17-20020adfe851000000b003197839d68asm2422140wrn.97.2023.08.14.02.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 02:36:27 -0700 (PDT) From: Bartosz Golaszewski To: Thomas Gleixner , Marc Zyngier Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 2/2] genirq: proc: fix a procfs entry leak Date: Mon, 14 Aug 2023 11:36:21 +0200 Message-Id: <20230814093621.23209-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230814093621.23209-1-brgl@bgdev.pl> References: <20230814093621.23209-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774198784066327532 X-GMAIL-MSGID: 1774198784066327532 From: Bartosz Golaszewski When removing the proc entry for a desc that still has active users, we will leak the irqaction entries. Let's remove them in unregister_irq_proc(). Signed-off-by: Bartosz Golaszewski --- kernel/irq/proc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index 83ed403991c6..b284604a091a 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -390,6 +390,15 @@ void register_irq_proc(unsigned int irq, struct irq_desc *desc) mutex_unlock(®ister_lock); } +static void unregister_action_proc(struct irqaction *action) +{ + if (!action) + return; + + unregister_action_proc(action->secondary); + unregister_handler_proc(action); +} + void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) { char name [MAX_NAMELEN]; @@ -408,6 +417,12 @@ void unregister_irq_proc(unsigned int irq, struct irq_desc *desc) #endif remove_proc_entry("spurious", desc->dir); + /* + * If at this point, this irq desc is still requested, we need to + * remove the proc handler entries or we'll leak them. + */ + unregister_action_proc(desc->action); + sprintf(name, "%u", irq); remove_proc_entry(name, root_irq_dir); }