From nobody Sun Sep 14 06:41:19 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 783EAC54E94 for ; Wed, 25 Jan 2023 23:14:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230324AbjAYXOp (ORCPT ); Wed, 25 Jan 2023 18:14:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230044AbjAYXOn (ORCPT ); Wed, 25 Jan 2023 18:14:43 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7AB83B67A for ; Wed, 25 Jan 2023 15:13:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674688435; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZxXC6RkcbYR55zhaEzAPuw/LbFxa4LSYY65NGg5ryZY=; b=GMV2PfU9DOfCx03bkpWoMyQlIx88nUudHNupts8L3tQDzvtslQhJsbFPEgwmM6iy6ALdWy mBRokXlXeAWnEd3rTGjnLyYA2L20ryCov2fR8Y9bLVCc/+poUWXH2S7ZUNZpMCcIQhkgOZ cXhr12sGxg30PLzxx9HDyTjLY6b9wcc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-411-hmWo8uBOObCoE9yJ5FisXg-1; Wed, 25 Jan 2023 18:13:49 -0500 X-MC-Unique: hmWo8uBOObCoE9yJ5FisXg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6AE13801779; Wed, 25 Jan 2023 23:13:49 +0000 (UTC) Received: from [172.30.41.16] (unknown [10.22.32.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id F399040C1141; Wed, 25 Jan 2023 23:13:48 +0000 (UTC) Subject: [PATCH] genirq/msi: Fix fwnode leak From: Alex Williamson To: maz@kernel.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, alex.williamson@redhat.com Date: Wed, 25 Jan 2023 16:13:48 -0700 Message-ID: <167468839713.2297784.1309086853550595503.stgit@omen> User-Agent: StGit/1.5.dev2+g9ce680a52bd9 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kmemleak is reporting pairs of leaked buffers when PCI devices are unbound from their drivers. One of these buffers contains the name of the interrupt as generated for the msi_domain_template bundle in msi_create_device_irq_domain(). This name is passed through irq_domain_alloc_named_fwnode(), where an irqchip_rwid is allocated, along with a separate allocation via kasprintf() for another copy of the name. These are the two leaked buffers. Resolve this by adding the missing call to irq_domain_free_fwnode() in msi_remove_device_irq_domain(). Fixes: 27a6dea3ebaa ("genirq/msi: Provide msi_create/free_device_irq_domain= ()") Signed-off-by: Alex Williamson --- kernel/irq/msi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c index 955267bbc2be..66dc956505b8 100644 --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1015,6 +1015,7 @@ void msi_remove_device_irq_domain(struct device *dev,= unsigned int domid) { struct msi_domain_info *info; struct irq_domain *domain; + struct fwnode_handle *fwnode; =20 msi_lock_descs(dev); =20 @@ -1025,7 +1026,9 @@ void msi_remove_device_irq_domain(struct device *dev,= unsigned int domid) =20 dev->msi.data->__domains[domid].domain =3D NULL; info =3D domain->host_data; + fwnode =3D domain->fwnode; irq_domain_remove(domain); + irq_domain_free_fwnode(fwnode); kfree(container_of(info, struct msi_domain_template, info)); =20 unlock: