Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp186243rwb; Mon, 26 Sep 2022 10:54:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4peKWMt1mGot2xA4JMG8FxNfgS6SdN/FpTOl0W/YjAJmU/8Ji4NJLuLZY0YQ/ZvPg08gv1 X-Received: by 2002:a63:86c6:0:b0:43a:bd68:5075 with SMTP id x189-20020a6386c6000000b0043abd685075mr20894057pgd.512.1664214858791; Mon, 26 Sep 2022 10:54:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664214858; cv=none; d=google.com; s=arc-20160816; b=QKreVofcoxkFuZXHuY7JofNP970NPjJi6LuVByxCRlLOXOqM3ZxJdI9JGIc0/htMFL CYLeH5MseoAZM+Q2Q9wvGsJHThaEY3Vt7q/ufbo8BBU6PLCTkK09rbQo2Xt9rahSllGm 8vgfuk6fDrF3TAumWHE+AeBJFHoS/AzJA7OZlWbIgiB4lPqtSbFBaDjTd/FX0DLnIVqp QWrWaC2kaqjWIuk/i6GscgrkijNvqjh3krWNU7z98xYOY/eVpwd9pGo3Xau7Hvidvk07 FJ4dV+6YF+Vykuy1MSnjptT3dDo8B6ME2JBH5KMv6mPLDkjmWAa/+MXnjVaI9KflPZOR Gung== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rTL3iYi4F7f9DBOx3idAOZty80MSHsP/AWEyCiw3sCY=; b=fx7Z79BpAzO5Izob7h6DOH7P+nomZpb2b5x6dk8dUXntDx2PYTkOYW/j7qSx8ZqSRW +sYU9Pm4iVD7S5B6yl87PHfYx/qc2oJgIpAY22Lrzy6awOfQ3NSOtAYdNlag09Hu+RXP F1dQAHO8YwcLD1T9AisuCtdd+4l8W2Kpruuqkm1JJVf9mHOezgwrzULLl5ASoSK9egC+ t8FoOfsPNHDMam4ed6GUOhcmSVYMJilhArRYenf0SSMab2/eMmtbTLdAkt77rYUn/VCp JwUilHmNzHdMGT+WstIyQ4CVI0eylvR8Cv0s/YXeFOcFQvLrxRq+Pj+Twwbs2UBnnrb0 lamA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B9VxvHOW; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w68-20020a627b47000000b00547e616f5eesi17637059pfc.126.2022.09.26.10.54.06; Mon, 26 Sep 2022 10:54:18 -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=@kernel.org header.s=k20201202 header.b=B9VxvHOW; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230101AbiIZRNT (ORCPT + 99 others); Mon, 26 Sep 2022 13:13:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230015AbiIZRM4 (ORCPT ); Mon, 26 Sep 2022 13:12:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 231EC1CB0D; Mon, 26 Sep 2022 09:23:31 -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 ams.source.kernel.org (Postfix) with ESMTPS id CC892B80B2B; Mon, 26 Sep 2022 16:23:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12BB4C433D7; Mon, 26 Sep 2022 16:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664209408; bh=3NryUWgV4wNFcxmk/xIXBo2lc6PqLNsFir7j/J5ql+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B9VxvHOWkGdHyuAUNDqCqlOxg64J4VVjtASjH5BQowJtyDWQK04xux3uC2Lnn5h/b PrDHkRjm3biuNgaFNpRDLtC0LGOHMXy2LsFtz7uO0XdOqRb+Eh4ivOmptA/35CS9AE 97gPV8P4XpmwkyFJwfaaTnPJGVJAGhX3Jt9lGsGaH0vIyxp426Yp0DFXZ1V6CjQq0T Th3Il54+19a9FLERiAON15iosTLwqWxoAYdJNf1gGmlbBYPj7NHlZ8EjnvVJX5kywR +fugilr2jLjXoD9mxnrbzQyvT57xD9145ZkkEUXa1cuHN5TUZy/GvncTnsQsxcuBG7 SC+gT25qjxAFA== From: SeongJae Park To: SeongJae Park Cc: akpm@linux-foundation.org, ppbuk5246@gmail.com, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v4] damon/sysfs: Fix possible memleak on damon_sysfs_add_target. Date: Mon, 26 Sep 2022 16:23:26 +0000 Message-Id: <20220926162326.49013-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220926160611.48536-1-sj@kernel.org> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 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 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 I forgot removing the closing dot of the subject and making the subject lower-case. On Mon, 26 Sep 2022 16:06:11 +0000 SeongJae Park wrote: > From: Levi Yun > > When damon_sysfs_add_target couldn't find proper task, > New allocated damon_target structure isn't registered yet, > So, it's impossible to free new allocated one by > damon_sysfs_destroy_targets. > > By calling daemon_add_target as soon as allocating new target, Fix this Also we should s/daemon/damon/ I will revise and send v5. > possible memory leak. > > Fixes: a61ea561c871 ("mm/damon/sysfs: link DAMON for virtual address spaces monitoring") > Cc: # 5.17.x > Signed-off-by: Levi Yun > Reviewed-by: SeongJae Park > Signed-off-by: SeongJae Park > --- > > Changes from v3 > (https://lore.kernel.org/damon/20220925234327.26345-1-ppbuk5246@gmail.com/) > - Fix Fixes: tag > - Add patch changelog > > Changes from v2 > (https://lore.kernel.org/damon/20220925234053.26090-1-ppbuk5246@gmail.com/) > - Add Fixes: and Cc: stable > > Changes from v1 > (https://lore.kernel.org/damon/20220925140257.23431-1-ppbuk5246@gmail.com/) > - Do damon_add_target() earlier instead of explicitly freeing the object > > mm/damon/sysfs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c > index 455215a5c059..9f1219a67e3f 100644 > --- a/mm/damon/sysfs.c > +++ b/mm/damon/sysfs.c > @@ -2172,12 +2172,12 @@ static int damon_sysfs_add_target(struct damon_sysfs_target *sys_target, > > if (!t) > return -ENOMEM; > + damon_add_target(ctx, t); > if (damon_target_has_pid(ctx)) { > t->pid = find_get_pid(sys_target->pid); > if (!t->pid) > goto destroy_targets_out; > } > - damon_add_target(ctx, t); > err = damon_sysfs_set_regions(t, sys_target->regions); > if (err) > goto destroy_targets_out; > -- > 2.25.1