From patchwork Wed Jul 13 16:18:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zach O'Keefe X-Patchwork-Id: 12916944 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 C2DD6C43334 for ; Wed, 13 Jul 2022 16:19:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 146AD94014F; Wed, 13 Jul 2022 12:19:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F675940134; Wed, 13 Jul 2022 12:19:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F27CF94014F; Wed, 13 Jul 2022 12:19:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E3177940134 for ; Wed, 13 Jul 2022 12:19:15 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B43993516F for ; Wed, 13 Jul 2022 16:19:15 +0000 (UTC) X-FDA: 79682586270.17.33124E3 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) by imf29.hostedemail.com (Postfix) with ESMTP id D8C25120075 for ; Wed, 13 Jul 2022 16:19:14 +0000 (UTC) Received: by mail-pj1-f74.google.com with SMTP id g2-20020a17090a128200b001ef7dea7928so1766772pja.1 for ; Wed, 13 Jul 2022 09:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=hYQR9cYgnhpx80q7EIyOUgjqtk6N6tNgFXbeVayaPog=; b=bsuGYAebF6GOpW+iSO7lJuTQ94HPdTWCjq46fyOfX1srABBhhEeYBGPMbSE2wNLIE/ /SJrbMba/MeXIyq4l9mzVyf/J2atIEWprepZd5iXV2txS3K4Mzgu2JiAM+Ihy2ht7Hjx eZWOKrbL29M26gr+PsAAvX50YewW2gvEh0Cd4tv0qBulWM6sixvCGpH4LbrwYZYPW9qm Bet1vxsn82C9HnucEMBjqEdeL1ZcWRwLlHiy7thoCvUQA8CWhkc+sTHc+umUXjwwD12E Sq3IParXXTdiX21y/mx9IiBTypCcIxo9uxXC6tcxfPnyNXgbXYUytezOSfoQ2e86q0qT +3tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=hYQR9cYgnhpx80q7EIyOUgjqtk6N6tNgFXbeVayaPog=; b=os7swyrpA7HSlHchxCxRTAaGEbPBxVBUAEjkcSIbc3Y+42x1vVVk98BtrQJfLWlQNO oKxQZWJ22QJHUTb21IsrpqkjZvgImqlGMhFwkPpbeZcVr4TCfAZw7yFeV3A80TObKLj9 HOKZXsl7K7FWQRm4BraSjU2HUtaqfxQ0YUcsSVdU6mwFoYbq3E6ZhDQ/J1ggTBteolDa iVa5HK56pLztXyN6v3zS0tN9stQ21weEcoZXqn6N3h1HdzgoTnAQ80cfzKAw4Dis+mew kPmrm8rnLDjGeXnrTBPK37nmWKSZ6DyX8lw+tzA9N9D4iRbd2aBOI61s8M9OQ7hN6sTf 0fLg== X-Gm-Message-State: AJIora94QknghlITpkPvzgq/Y5702UlpstBV2s91jMfvz6aDAenZlZmS gGX4dNNZR91JhXnZNphVuJ49BN6OvJXE X-Google-Smtp-Source: AGRyM1s3CUC0K3NA57OTMc6a+to4LFZeF9RS2RtYNat87Mee0fZQZOzM2uZyy9JVLaUIqRFjGtw6aR8xDWvv X-Received: from zokeefe3.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1b6]) (user=zokeefe job=sendgmr) by 2002:a17:90b:3b51:b0:1f0:5ebc:ac9 with SMTP id ot17-20020a17090b3b5100b001f05ebc0ac9mr4579106pjb.229.1657729153787; Wed, 13 Jul 2022 09:19:13 -0700 (PDT) Date: Wed, 13 Jul 2022 09:18:51 -0700 Message-Id: <20220713161851.1879439-1-zokeefe@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.37.0.144.g8ac04bfd2-goog Subject: [PATCH mm-unstable] mm/khugepaged: add missing kfree() to madvise_collapse() From: "Zach O'Keefe" To: Andrew Morton Cc: linux-mm@kvack.org, Dan Carpenter , Souptick Joarder , kernel test robot , Yang Shi , "Zach O'Keefe" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657729155; a=rsa-sha256; cv=none; b=0enGBS1BaSuUTWRfJCLby1njPny8KpnExQxdVSgcFW+wOigAPl5LG86y+lbVTlL+6jZBjg 04eIgu2AdRfDtZs/iN4awL6dp9p6LswrAtLmtkdnzIfdRs0x131+U+uHvluTvzaka2IUvR 3T5CpRFw8Vho7y1//YHiqK+prIa7mAk= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=bsuGYAeb; spf=pass (imf29.hostedemail.com: domain of 3gfDOYgcKCLo4tpjjkjlttlqj.htrqnsz2-rrp0fhp.twl@flex--zokeefe.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3gfDOYgcKCLo4tpjjkjlttlqj.htrqnsz2-rrp0fhp.twl@flex--zokeefe.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657729155; 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-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=hYQR9cYgnhpx80q7EIyOUgjqtk6N6tNgFXbeVayaPog=; b=ralpxTl8MQ9QmbEwkYPcN/AhgRMntL8UyG4zVkR5H1gbFDApTeQttbAZa5U27G8avXLUV7 fNrWhfuH4wwaLb6NZqVgg0cwCPvnHJL2SZtpcSu5sk8g/TXJrWpVy9F7Ru9+xNyov58CYp ZaOoNi8+5iWMFfFeWGm0FmzTeYSJQ9M= X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D8C25120075 X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=bsuGYAeb; spf=pass (imf29.hostedemail.com: domain of 3gfDOYgcKCLo4tpjjkjlttlqj.htrqnsz2-rrp0fhp.twl@flex--zokeefe.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3gfDOYgcKCLo4tpjjkjlttlqj.htrqnsz2-rrp0fhp.twl@flex--zokeefe.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: nzkah8e5rofi83i5r98zm5s686c6udj3 X-HE-Tag: 1657729154-761766 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: smatch warnings: mm/khugepaged.c:2409 madvise_collapse() warn: possible memory leak of 'cc' Link: https://lore.kernel.org/linux-mm/202207100715.TBIYQ4fc-lkp@intel.com/ Link: https://lore.kernel.org/linux-mm/20220713024109.62810-1-jrdr.linux@gmail.com/ Fixes: 3f7416127072 ("mm/madvise: introduce MADV_COLLAPSE sync hugepage collapse") Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Zach O'Keefe --- This is in addition to the patch submitted by "Souptick Joarder (HPE)" : "mm/khugepaged: Avoid possible memory leak in failure path" --- mm/khugepaged.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 0207fc0a5b2a..944cf6c8a252 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -2472,6 +2472,7 @@ int madvise_collapse(struct vm_area_struct *vma, struct vm_area_struct **prev, out_nolock: mmap_assert_locked(mm); mmdrop(mm); + kfree(cc); return thps == ((hend - hstart) >> HPAGE_PMD_SHIFT) ? 0 : madvise_collapse_errno(last_fail);