From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC11418C2C for ; Fri, 26 Jun 2026 00:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782433181; cv=none; b=dGvK3l4Q6Iprv+g0UhtJqTLhpoQQfrbZ3BAaYlMZRyzAZVXXlWNCtMT1pTSvPbkesBYaQ/8TFvC2jdjwzEiI2fE+qle62ApU2jTdJaghpqOTqIFXVIGGShVt4vMaVFJLIK1glW1oPXusjjCVLU39n/c0u3hZQDIGoQcBFazZ1Do= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782433181; c=relaxed/simple; bh=xlm6i6xe1uD8q2AX16DRxyjiP55aoCo/Dvd6NqPoXuU=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=q3ttwJ/v/jh5U5ovdqtirx0aPflhrc0Y12B+2BwjI1pQJ9+16wZoP0wjZxr7TXnHJoljYshSpxlrZRom/MmNIetHOIoLhq17emkIN0qyA/wS4hPOIBMv5yZ14iEHbHke7579tfDha4PGBJIw7za10fliyHy9jChlEv4Y+AUoG+o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=gc2i3YDn; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="gc2i3YDn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D2511F000E9; Fri, 26 Jun 2026 00:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1782433180; bh=Bdmk6ysU5Vfs4V4qQFRsUc7N0ch9cjdG8d7Ue6lHxb4=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=gc2i3YDn1nNLN2uJTB5gYqVdMLQIyTfe2yyigsqFYWWAgcE27LRzzuF3hOWqR2Dco YxhfgezIy9svp5og64V0G1sqcSfHSJVhfIMUZmNVDfevF/xxhsnJVCKq3IgL8UvEJc xvfJrQyjlKvQ0fyUj4hXnbwAr/N82rtVKlDdLrdQ= Date: Thu, 25 Jun 2026 17:19:39 -0700 From: Andrew Morton To: Yichong Chen Cc: vishal.moola@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v3] tools/mm/page_owner_sort: free per-record allocations Message-Id: <20260625171939.6b920a87159a1cc695ec4de2@linux-foundation.org> In-Reply-To: <610C3A89A09303F8+20260612055017.632263-1-chenyichong@uniontech.com> References: <610C3A89A09303F8+20260612055017.632263-1-chenyichong@uniontech.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 12 Jun 2026 13:50:17 +0800 Yichong Chen wrote: > (how come so may people are working on page_owner lately?) > > add_list() allocates comm and txt for each page owner record, but the > cleanup path only frees the outer list array. This leaks both buffers for > every retained record. > > Free partial allocations in add_list(), discarded records during > culling, and retained records on exit. Return explicit error, skip, and > match results from filter_record() to handle get_comm() failures. Well gee, there's a very reliable way of freeing all the allocated memory and there's a syscall for the purpose - exit()! Really, everything below the "out_free:" label in main() can just be deleted. But oh well, the code does make an attempt to clean up after itself so I guess we should set a good example. Thanks. btw, AI review flagged another (pre-existing) issue which we normally wouldn't care about: https://sashiko.dev/#/patchset/610C3A89A09303F8+20260612055017.632263-1-chenyichong@uniontech.com