From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 542832E6CC8 for ; Thu, 11 Jun 2026 08:34:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781166892; cv=none; b=Obc1j0VIMRvY1Yok62PXks+bzT7ghqBJmeqBg3iY4bmZGP1yPuC7ecdgeTRtWIYHT40f+gV3kwl24/h95Eo+bgX6PKhmBpbmCCor2y/5Tg62aLocY0M0JZDHm1MSo9PMXrps71phJRff/rWmyQIlHFH2fOMpfY6Gh2f8kUiPewQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781166892; c=relaxed/simple; bh=NDKZNCRJFULyvSjGV264OOTyVv3C1FXT7R3QxmezIxQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UZa90xVW44gj9aO5tYvHP4QDPt1kJrcdJdMIN87MdIoZI3NIMqbN2ylYBbrlnCJhCqW49gKrkFhhyAKcZf7vzPJuuuGSSqswvM+JK8p87nf1iYKfuBp5I+aXA5PVrJAwf6SetKiWm4VQmRGoSEqxVhY0gC186bTm4T7M0M6AbYE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kKX5Ayxu; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kKX5Ayxu" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4908b92904fso87779285e9.0 for ; Thu, 11 Jun 2026 01:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781166890; x=1781771690; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2UMrzR2+SVHqKWgSYoVZBjp/ERVOIsPlQNqX6CP0Vdo=; b=kKX5Ayxu04Xl5fYb74i2tfIxadXjhhyUnsQmpEKMVaaWC6C3ON2leaee7erSyvc0xx b8jkG+h7nLVtpoMRK1wrvA0lkLVH2l0dVLBGI616kjvKkI3p3qvty1Vpk2mCOTZ6zGCm CpxPYFo2PrRZNHPaqaFUV1UgqihIoe++nyRYt3wjCvVjMpB8p5q1lkvMNUuYZ6BcN/rB SZk1YM9Y65jhDygpq5YNmFeRSMLsK5RWs6gs09+5Sv+S6ded4mSN5vFEjCgaJTzQSVIw U/ObNNSq4e4qKvjYFoqZslt+6VFTp5btiJtsEOUjRPatF5buLUAlyKwiOCtHcnyjgf/p WTnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781166890; x=1781771690; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2UMrzR2+SVHqKWgSYoVZBjp/ERVOIsPlQNqX6CP0Vdo=; b=WxhKhoExOqk3kY0nrwrbJ2P4+EjKohQQrmTkFtF4k35+xdeFq2P0dEucL8RoPq0p8F fkmSseklBfnYFVE11BuRaLgx73gByq9kKalMwQlOVgMO2wJ1sX7Tpg73pWr295DURhhu jsJWPNVnDuThyZX1z91DL6ZBCz+g94HUssWJfkRIwcsd9Zxotrtlp9AnDVydWMNisZb6 y1MGIh7YpyaHYi24IzSxt8j3xH9r96IM7Sx+ilWc1vg89Sb6rozWiDggEXUwYNtiEM2d UINVt+uhEmeoGXeiVfMBQ0mcybon79cK6ymabPxwIp+QEox40BYeSTD++GKbHUI1Z1IB AZ9A== X-Forwarded-Encrypted: i=1; AFNElJ+tSnAf7cwH2CHZiy5cjBf39vaHWSYgxVR1kPZvR3uJ8wFwJYaPRijzaz/hRn4i1eUeriMaRW7Tcr2djCs=@vger.kernel.org X-Gm-Message-State: AOJu0YyHui5os1p2QdnCrHho5WTl2hEienxjdvYoCs26XL3Fhc0/lt7v eeOBi93FLDGntBAZMOhXXuA3tUyqmrnZzs9O+ndFq1+7oIZIOCO+KFXs X-Gm-Gg: Acq92OFkIchCS2VFez72fpm+L2x9xXCj8dlKSNAEA5w7E4TvnjF6HF6Oasul86ac0CW /n9aCXzMgtYdENftH42OlS5+O3e8i8wIrh46alAceHCneQoWlzteN8DiTiuPoY/IrkeYiZldevN ZmFuHTPv2iZMSsU0BxbyQdplsiW6aXnWmWuGlWKRNta3tPN1CRixJCMMEUVlhEbusYT5Gpd96mZ uTUV22jX5hV4ypD5iwZ1yp7Ssn6GhE9VrjM5atpgRleOS/wBDLNVPFvGpj78PamhYnzjRnlbf7A ibGM/E491KoMppcnrVRm5QH8oHXDxHnfrxVtytTBxyeluJqheOO9akpfk2B8GIKLmNsR2KByLN0 +ubxLGsLkYZmG5tYB/LDO3b+rUxGH+QJlG4HNhR8ZvDQx7CY/zNCEOGq5Bjy+yXwY3PnxSEOxOz eCweGPwpFJOTQ4ch4WxV7NegLzVeT5WtvE/r19HhXs+zaj8G218SYwvuT7tJU5QK0ins2TQewWO LxmiAmtupWJR5wDRBPLE2n//obGAH+DLefHblRPH0EJ X-Received: by 2002:a05:600c:4e0c:b0:490:bb45:79ee with SMTP id 5b1f17b1804b1-490e5379dbbmr24840205e9.0.1781166889422; Thu, 11 Jun 2026 01:34:49 -0700 (PDT) Received: from fedora (cpc92878-cmbg18-2-0-cust539.5-4.cable.virginm.net. [86.16.54.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2e4004sm79045230f8f.9.2026.06.11.01.34.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2026 01:34:47 -0700 (PDT) Date: Thu, 11 Jun 2026 09:34:45 +0100 From: Vishal Moola To: Yichong Chen Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2] tools/mm/page_owner_sort: free per-record allocations Message-ID: References: <440C4C1E0D13E6D1+20260611023411.379986-1-chenyichong@uniontech.com> 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-Disposition: inline In-Reply-To: <440C4C1E0D13E6D1+20260611023411.379986-1-chenyichong@uniontech.com> On Thu, Jun 11, 2026 at 10:34:11AM +0800, Yichong Chen wrote: > 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 discarded records during culling and free the retained records on > exit. Also unwind comm when allocating txt fails. > > Signed-off-by: Yichong Chen > --- > Changes in v2: > - Wrap commit message lines to approximately 75 columns. > - Use "Yichong Chen" as the author name. Thanks. Also, in the future send new versions as new threads :) The patch looks fine, just see below for my comment you might have missed last time. > @@ -480,9 +489,15 @@ static bool add_list(char *buf, int len, char *ext_buf) > list[list_size].pid = get_pid(buf); > list[list_size].tgid = get_tgid(buf); > list[list_size].comm = get_comm(buf); > + if (!list[list_size].comm) { > + fprintf(stderr, "Out of memory\n"); > + return false; > + } > list[list_size].txt = malloc(len+1); > if (!list[list_size].txt) { > fprintf(stderr, "Out of memory\n"); > + free(list[list_size].comm); > + list[list_size].comm = NULL; > return false; Returning false here sends us back to the error handling path in main() where you end up calling your free_block_list() anyway. So we don't need this here, right? > } > memcpy(list[list_size].txt, buf, len);