From patchwork Thu Feb 2 14:13:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 13126139 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C831C05027 for ; Thu, 2 Feb 2023 14:13:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C2DD510E531; Thu, 2 Feb 2023 14:13:26 +0000 (UTC) Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3B79010E517; Thu, 2 Feb 2023 14:13:25 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 1C4F4CE2A97; Thu, 2 Feb 2023 14:13:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF18AC433D2; Thu, 2 Feb 2023 14:13:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675347194; bh=1pMG7Pa76jFEvorIxfR7GamBOmkilJdNM0nQDHmdpiA=; h=From:To:Cc:Subject:Date:From; b=QwVaovFY3zDMEMHDj2Y6qrtKovByOCCSkyPSUzLpi0+ijNdTtDrc+9N4l4EoE7Htx NrI124W2PX4lWafSRbs+bd16YNbUChbB4X6IDMB4Fqn1AA+g825dXULjT2sWnwwg4Z nhZ8UuN2nUjP1/EyqNDcD7Jd17jY0c90GtPqcoVM= From: Greg Kroah-Hartman To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH] i915: fix memory leak with using debugfs_lookup() Date: Thu, 2 Feb 2023 15:13:09 +0100 Message-Id: <20230202141309.2293834-1-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1462; i=gregkh@linuxfoundation.org; h=from:subject; bh=1pMG7Pa76jFEvorIxfR7GamBOmkilJdNM0nQDHmdpiA=; b=owGbwMvMwCRo6H6F97bub03G02pJDMm3j3zVNZ3sfIL/45+LPg9f+1bHb/XbsPY8L1s045Q+w2q3 rVJHO2JZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAi5mEM8/QfTqif/WPVbvUjEgJ6/j /DVtx3Ps6wYN6dhy57F25M+vcydiaT/MRcM7398QA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tvrtko Ursulin , intel-gvt-dev@lists.freedesktop.org, Greg Kroah-Hartman , Rodrigo Vivi , Zhi Wang Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. To make things simpler, just call debugfs_lookup_and_remove() instead which handles all of the logic at once. Cc: Zhenyu Wang Cc: Zhi Wang Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Rodrigo Vivi Cc: Tvrtko Ursulin Cc: David Airlie Cc: Daniel Vetter Cc: intel-gvt-dev@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org Signed-off-by: Greg Kroah-Hartman Reviewed-by: Rodrigo Vivi Reviewed-by: Zhenyu Wang --- drivers/gpu/drm/i915/gvt/kvmgt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c index 8ae7039b3683..de675d799c7d 100644 --- a/drivers/gpu/drm/i915/gvt/kvmgt.c +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c @@ -699,7 +699,7 @@ static void intel_vgpu_close_device(struct vfio_device *vfio_dev) clear_bit(INTEL_VGPU_STATUS_ATTACHED, vgpu->status); - debugfs_remove(debugfs_lookup(KVMGT_DEBUGFS_FILENAME, vgpu->debugfs)); + debugfs_lookup_and_remove(KVMGT_DEBUGFS_FILENAME, vgpu->debugfs); kvm_page_track_unregister_notifier(vgpu->vfio_device.kvm, &vgpu->track_node);