From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 AC30030D3F6 for ; Thu, 11 Jun 2026 11:50:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781178658; cv=none; b=MkgV8kOQWLAawV6MKWNpRqgjIli+RIIE1ydFUBXucqO5EjaFhbRlhQhr5OQJ653fKiUeMkIjzK5R3/thJhByR9E3QW1FVQ1SHmd5/H+viWD+5rFkscjurb7NCQw9khc6KQQJwKqOII4sFn8RyEQUVBi2rclFMT6fSftzYof9JT0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781178658; c=relaxed/simple; bh=A2CjJawEf5fHk9ldaCnPKUZ48Fk6z/e0XYrCadfOpi4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SnKe2DF0zMJ7cl/jkIy/F1Gc0n7Jw8kTBHg7X5PKTp1M2vmPOThkfj3gyl42Y/6nO5KGbsUFbCQV1xK9qv2XRi5D648Nu80V/C1yUGKlLIJ/52IEEh0H0cfFyfcfCCNe0ys6GwwKl7wU5SwSRAIzh5kRas5yVy1L/Z4NkrWK9EY= 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=NcsViXda; arc=none smtp.client-ip=209.85.221.52 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="NcsViXda" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-460662fcb4eso521471f8f.0 for ; Thu, 11 Jun 2026 04:50:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781178655; x=1781783455; 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=yrzlJyLu9uNWqK5gmAkFzGANXofsBniaCTW8GnMk0r0=; b=NcsViXdaEwyN8REEpRsT9fQdnSdl5rPvJF0PXdtTfaTNbxaV0Kgv+2yKAP+Xw94CyL nO4est+H1B0h5yf4GtvFrBXzX6OrnXCtcE3wLrhpK0YYpPEGEvbmkEzAMnWbEqyfIOsN g/MfOqoYrLk2QijV7v/fQRbt6k5qyXOJqsYzY8AcBpoV33jED03YF1OxKhNNXmi0PLzn rsno+bFG4m8GHFzzLnLZq/zcmHKfjreJawsrk+dxSjw1AeB1T+Y13efE8D3HfQoKwWGp zT+lwZgmNjuKojxXXt50Nb3oge1KCnW+5t1rmI0q8CcwMajW51e+ZoLNRYQurnmKLkIj nA5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781178655; x=1781783455; 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=yrzlJyLu9uNWqK5gmAkFzGANXofsBniaCTW8GnMk0r0=; b=Y4u3by56EWPHKQObCiIw86aQXJrmM+/kSD8HNCS0p1j9u2QcCAswpEzEMOoJXT5iZM ofbG/0cjZ9NpGu28hsyauXJAZDb2WwcgsOw4+xvJJsoYtCN4XXy9jZRTtT4wxbQenBaW Ym9A16JXKj0T6BULkAT3eSMWe9u98w05DWmWS9JkpDvgmVjSgg1nZOrb2u2ZPECDBZO6 07K+1fiPAK5vpMiMsEGjiBT4MEUHiyEP4KAN4ol6BXSltbgM7EkriwkP3dym85pNteUx ZpRP//zlok0inIUD3cX+rOtrDZyC5wfDo1HjLSsELPJGpgjgvcPQLLMdgLJyLZU9aenA OtSA== X-Forwarded-Encrypted: i=1; AFNElJ/Lph/f9WhEPhQfUfqK9eObCJ7rnQNThpSJIIZfhiHsbYAdXUfuaiim9E7y8NZRDRnCmWKJmTHL4YTRCyc=@vger.kernel.org X-Gm-Message-State: AOJu0YzU5Dg8Mj960CTKDHHOc/aoev12LRB5lxmgqNmOBXFQWUhdGLvC s6KgBfME969Q0zzfJhb/vmgHd9EGyAQVD0a2Oqr4q4wIu4HW3G7fDcgBRE/aOw== X-Gm-Gg: Acq92OFNX4eTJNy+BWrGtYmJmM7xv8MUb0VgIA4By4/ZtQO6kO826uavyO6byzF1UBJ h/wOmj//+XB0r6aiorrEDrdmpgU1E+B2K1W04amzsXiyRuZtoKnv1dPk2PN7dmGwY9puyD79lZp //uF/nyPUSva6YfXbmebOkZtVplDhzDrMy4HusIjmQtA619TYeXFnC71N2pS+bC8lvY+qDwVVrp rq6CZofwR1+NiGOeBKq8/wenw+8XFGbT+UAtkHyWtQJVMl0Emz3W1ek7ojxGWGLd+bZZO5cENKv KjimtRHkzIQ2Syc/zcMtMnjIv3s6SXzf/KzrHnPipuepMXBYmnXnk8BVDMsSBFgyJRHhJkVTViI 0Gb2uTN5QXzwzJ61Rk5JkJzdjOcDMJWP8niTjJJMz+nHznjXr+gQMLPBddLqAKzcondFizd/XvG pKbyHbqsuFdeCZVUrmKkcCW9hg+DQC9rOvvQ4A2Tv6Chg+wAyk4ICo1gAJYS8XCJpbVXcPaEKfX hbJsphq7QeIDerddFAy+a5bqdvrLS99tKnYkqke9Uxi X-Received: by 2002:a05:6000:702:b0:452:8286:86bf with SMTP id ffacd0b85a97d-4606758caf2mr3422666f8f.1.1781178654810; Thu, 11 Jun 2026 04:50:54 -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-4602cda363bsm68265267f8f.31.2026.06.11.04.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2026 04:50:54 -0700 (PDT) Date: Thu, 11 Jun 2026 12:50:52 +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: On Thu, Jun 11, 2026 at 09:34:45AM +0100, Vishal Moola wrote: > 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. Sashiko also caught that is_need() calls get_comm(). That looks like it should be handling the NULL return case as well. It appears to be an existing issue, but it could fit into this patch if respinning for v3. > > @@ -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); >