From patchwork Fri Sep 2 12:56:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 12964120 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E11FECAAD5 for ; Fri, 2 Sep 2022 12:56:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B09EB8D0023; Fri, 2 Sep 2022 08:56:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB9E58D001B; Fri, 2 Sep 2022 08:56:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 981468D0023; Fri, 2 Sep 2022 08:56:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 89EDF8D001B for ; Fri, 2 Sep 2022 08:56:48 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 585A7ABB0F for ; Fri, 2 Sep 2022 12:56:48 +0000 (UTC) X-FDA: 79867144896.06.7CAD20A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id 08C7EC0051 for ; Fri, 2 Sep 2022 12:56:46 +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 dfw.source.kernel.org (Postfix) with ESMTPS id E807961F50; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662123407; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=+D0umswYPMhlR8u0FRFgoyHFB4zbmg8KXKib2i7BKCM=; b=xlvpIqGIbTouTbh03FKgFrXYFoucmI13hj2gn6PvclME+Zd9JKiRzvd0LACWxm+SyXdN3r 690toLeBepDqy189kiUC8kkg6hfXiwbkdvvIn/6QC5Jp00ZHtiylQRPHtTPv9auh9VBALS 48Jlu3i3WjLwYbWiEfDFYQPruP/7q6o= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=nsvDjFmO; spf=pass (imf22.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662123407; a=rsa-sha256; cv=none; b=HtuZtqQW7QfIgJNlRdHZ0ZdrVhLJLr8yc3z2ejlWom/8Pnmg80GTsN7oSCuDGhtdbaMvMq kHnnlHlnF6Pk8M14G/r+Y9Tyg2PKHLqggDKhBudp4KiSv18FPOqNua35D7GQ2lbLcssxrY FWnJMAMpGWCWVGhmtub02ROTdiWxfoI= X-Stat-Signature: iujspouyj4fkmg6s5tkwemhhwp1tebpq X-Rspamd-Queue-Id: 08C7EC0051 X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=nsvDjFmO; spf=pass (imf22.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org X-Rspamd-Server: rspam01 X-HE-Tag: 1662123406-457897 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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);