Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2027479rwe; Fri, 2 Sep 2022 07:32:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR6dHaorNj/41raCm6jh82jcSAED7gl4MxghXDwK+F/g8+5Mr3EQqx2NFlmxO3Ezg1Bi6N8D X-Received: by 2002:a17:907:2d87:b0:741:85de:ead6 with SMTP id gt7-20020a1709072d8700b0074185deead6mr17047017ejc.531.1662129153997; Fri, 02 Sep 2022 07:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662129153; cv=none; d=google.com; s=arc-20160816; b=Z+gWRgwdS+3hCCbXS3wmriewToeXQSRGY03DA5T0fIbR2U5J8VIvsQxVieYTbDe1h5 TnDkxaCCpSybr3TVqZ3atnLymUp2i/NSvifim3k6fdID7QYeJbLpstdPg7z7uRq4vx+5 A/hkB3TmwzvVn7QIxjmLZ0rarj01b8vuZKQnGy4Vxyo33KoPQs55BrBQTX5OxdK6OqT5 Mzaoz5FMxa/RZIpkoe23vWDVfB8zCAt+yRHAr3hXWeXhQ32NRN6OCpYKQ/76rHsnbP8h H3c4oK2Jv2orxM3NvTaBnOlkSNN9mWj4HhTxDRbbTb/d0a1af0idnsNkMSqysh/cCyjY vzVA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=+D0umswYPMhlR8u0FRFgoyHFB4zbmg8KXKib2i7BKCM=; b=TD0yCtBof97CPtBfKT4XOYqIJhSOzH7oUF46CcJbZ2VSkQXRQ2IrGTHOjO9aG/cTGv c8Y+akDfg53YlW1Gx/HId2GBSvnizszCLoaQi5tvbTQDvPPCG9uy4XchQRVK9bpeObm8 IKCrS8Ko9ZJaQYA8v6LvkgKnBZ152MMejKpZeow0hOUzyEgelktkTknU5DccQKKNT7/l B3dHwn7+diLnWudrlApKSwx14DEpupPr+3leUFtEsXySnpwEJm7sxnJZm8vPQo2aVZ2o iVMtC3GxYY1/Qc2CIYNlbt0JbfafejJqtpSsz4X17MxwcqDXgyrhvIxrtB/qRJJ4m0lb EOhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nsvDjFmO; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v6-20020a50d586000000b00448f0a4f4d9si1883572edi.61.2022.09.02.07.32.05; Fri, 02 Sep 2022 07:32:33 -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=@linuxfoundation.org header.s=korg header.b=nsvDjFmO; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236795AbiIBNg1 (ORCPT + 99 others); Fri, 2 Sep 2022 09:36:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237324AbiIBNf6 (ORCPT ); Fri, 2 Sep 2022 09:35:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECAC579EED for ; Fri, 2 Sep 2022 06:15:23 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 83E6F61F4F for ; Fri, 2 Sep 2022 12:56:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61B5BC433C1; Fri, 2 Sep 2022 12:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662123405; bh=HGl9Pb/xwY2wEwqJGiEKgOcUViCJqmT47gVsSgc8WXA=; h=From:To:Cc:Subject:Date:From; b=nsvDjFmOlgGYDfmS3pJhN5oHEGDJHFBDEfjiU9rM0rwL9WhCHWyXpsohTna4AnIHX OVsvYJTHZYWnO+dqUZ+UioiveqF0OTqmEBJeRNCfpwCeRE/VnSkHYYR3TNpNB1zicb OLoOoVw/8yXI5qbgYmWz/yVfQBT9n0HMmFrkMy6A= From: Greg Kroah-Hartman To: SeongJae Park Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, stable Subject: [PATCH] mm/damon/dbgfs: fix memory leak when using debugfs_lookup() Date: Fri, 2 Sep 2022 14:56:31 +0200 Message-Id: <20220902125631.128329-1-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=771; i=gregkh@linuxfoundation.org; h=from:subject; bh=HGl9Pb/xwY2wEwqJGiEKgOcUViCJqmT47gVsSgc8WXA=; b=owGbwMvMwCRo6H6F97bub03G02pJDMmCf2uuON1Zwc1X3R7CsCxz7eJ1cyTj560+/KuG8eUeCc8o D/2AjlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZhIshbDbJbDjyybpHnPOFx+7cl/q/ mbpPWdSoZ5FheXHOx//unz9s8cjbJS5uedbwVsBwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. Fix this up by properly calling dput(). Cc: SeongJae Park Cc: Andrew Morton Cc: damon@lists.linux.dev Cc: linux-mm@kvack.org Cc: stable Signed-off-by: Greg Kroah-Hartman --- mm/damon/dbgfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index cb8a7e9926a4..dfb6ef8c83e0 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -915,6 +915,7 @@ static int dbgfs_rm_context(char *name) new_ctxs[j++] = dbgfs_ctxs[i]; } + dput(dir); kfree(dbgfs_dirs); kfree(dbgfs_ctxs); -- 2.37.3