From patchwork Wed Jan 25 23:13:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 48411 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp538176wrn; Wed, 25 Jan 2023 15:27:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXuXTDAKc6kOiTH6V999LIbj/VlYyz8FcI27ipzBrd0ONCvMHxzOnKKtSY5KYE7Oa9g/eWMr X-Received: by 2002:a05:6402:520a:b0:49e:a080:d55f with SMTP id s10-20020a056402520a00b0049ea080d55fmr32985722edd.18.1674689244013; Wed, 25 Jan 2023 15:27:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674689244; cv=none; d=google.com; s=arc-20160816; b=eNmBFVl+2pnUJ5SNy/E+KImaOkKZ8/PWsilM+CvqXbTWBUT5HwJBEXpm7fDnvMiEgw vv8j1qj82uj2JSZ8RXKyk5YVjWC79qYtEQstUvJgUv0C8LRbTmW522984fN83yMetEKj CuIvCQd5+bqaZYnf8498CJNZ6g7F6pH2GJp97zivW/3s2w5DK4b90a8R5rNrLoLVvA74 OHJ0p9Cfzme19EHo0VpzUNtO549wr92DeFdG5zc50bkPjEvu7yVXt0oY5f+IVeencwOA nQSxMZ7jNVcxTNKE4MAHMoalIoz+2aeDkh6a16A2l7qAVuRBYigwjcoUqn4y1ijOej/h st2g== 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 :user-agent:message-id:date:cc:to:from:subject:dkim-signature; bh=ZxXC6RkcbYR55zhaEzAPuw/LbFxa4LSYY65NGg5ryZY=; b=niyeGgvC0qXXyXKefxmpH4hb9oYm3jdY1wvYJQwqOM57Pr+sOq7aSriNgZ1Q0RscVR MVd/UzMGIfmdXOCPS7wYzrPnTmW5koXorvDP7sECTmcZuTlKw12qVGWl6ThRqahGbyrk QcuS4gqxtDqg+1b9EZm5StErlg3sF6GzWo4TdlT6/FE1Vz5jqpt/un+dvDPOu7pVPbMg UktVurQ1nNs2z8COLMijmKR/kPpmQgWyaZCuWvFxHNm8DGYVBAafDgXTqo3yhjzHTI2G zXW/JueG23rhUM1vMP1Vrf5cyWPeIkUPrz00X516mZcKzzzcAwqV7ceVLxdjGC4am/kZ oP0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GMV2PfU9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v28-20020a50d09c000000b0049defd69a6fsi7939764edd.622.2023.01.25.15.27.00; Wed, 25 Jan 2023 15:27:23 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=GMV2PfU9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230423AbjAYXOo (ORCPT + 99 others); Wed, 25 Jan 2023 18:14:44 -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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756038948733796004?= X-GMAIL-MSGID: =?utf-8?q?1756038948733796004?= 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; msi_lock_descs(dev); @@ -1025,7 +1026,9 @@ void msi_remove_device_irq_domain(struct device *dev, unsigned int domid) dev->msi.data->__domains[domid].domain = NULL; info = domain->host_data; + fwnode = domain->fwnode; irq_domain_remove(domain); + irq_domain_free_fwnode(fwnode); kfree(container_of(info, struct msi_domain_template, info)); unlock: