Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp51947yba; Fri, 19 Apr 2019 20:11:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBbSSZkTR4OazXfXJdWyl5sURvKbs5CMHO9PWbdnSpMMihFUjHXQH3BrTJLpfm1Qa2eG0x X-Received: by 2002:a63:10c:: with SMTP id 12mr7488208pgb.276.1555729871412; Fri, 19 Apr 2019 20:11:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555729871; cv=none; d=google.com; s=arc-20160816; b=x9r15u8ck54yCRMckz7PqPAwyuiZXhgzPZXLiOSQt/m9r9VqlxutA3Yk/YPjVRoj08 amqc28zVY/NTmAicvkqt0pPsJ25KAdiDRPNMigU02iMQtCnB2Z0RE7wxs2bx3LmVKvoD aF2425NGQjzZZ3rWZiWjls3ggzMNDMjCMl0GNyVZwrGU1b0PmwSDhscfj7FGh/onJC5O BDpuUyVgzExqACaZe26vOU5op8xS5R+ra2yeeBensI41cqnXKWLYWJ8Rff4tw4P0XKhX qsiCAE/LVLmlCc8/exsNw65Cwzo8uQj363EYA0j6JZydofBtZdvc+LoWdifKvGfJofFi 5DYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=FyO9SkKc0KZdryFE/meHvxbeKd4PewE0fzY9JSJdgwQ=; b=c/nsQ9VoJg5E5GsXRb5cRA0pyiR6O4c0Y+aA7Wif004u3bK2gZEtU2rYnbIctTssNg DSsLApmBzePeexkwVHE7+hpZ4YMlwtRy/Q9uLlGzqtFrVDNVb8c8nDJh+p5PqfiBh0LI fDahO8d6RZOZ9bodCjMT/3BolrDdr8T8Rl41GDmSYt2o2lnSYChxYaQAWICPYgwx73I5 IFnPd1nLcSR1STHNYaOMCGGXIhTHUfrqnL8/qCtz4g5L2Whu8z0ABEVa8ViBvPIL4ek3 Y5tTAdY7/SB22VDlDelJ0khtbDhtTw3SYqh4cf1ow14CiNJsDrtHnN1/VGB6Q+3WbgBY PqFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umn.edu header.s=20160920 header.b=QN1SD40H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umn.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n9si6099206pgp.539.2019.04.19.20.10.56; Fri, 19 Apr 2019 20:11:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@umn.edu header.s=20160920 header.b=QN1SD40H; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=umn.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726150AbfDTDIr (ORCPT + 99 others); Fri, 19 Apr 2019 23:08:47 -0400 Received: from mta-p4.oit.umn.edu ([134.84.196.204]:55720 "EHLO mta-p4.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbfDTDIq (ORCPT ); Fri, 19 Apr 2019 23:08:46 -0400 Received: from localhost (localhost [127.0.0.1]) by mta-p4.oit.umn.edu (Postfix) with ESMTP id 50E52A47 for ; Sat, 20 Apr 2019 03:08:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=umn.edu; h= content-type:content-type:subject:subject:message-id:date:date :from:from:in-reply-to:references:mime-version:received:received :received; s=20160920; t=1555729725; x=1557544126; bh=FyO9SkKc0K ZdryFE/meHvxbeKd4PewE0fzY9JSJdgwQ=; b=QN1SD40H4M/u/6nMJvuXGfj9qo DV1U9BCVnHzqie7jsU2RalJAhgyn/U7yTxW+yuTpk3kXzqr7OP/eyVOxOeCJUABn 8aqULXiU21nK5FJu61ZtFH6Un6xbKwnX0W4Yl1/C1me9VAsVO7unCzZNSRMa0Oss K/ARd+F0VdLyw1RLc+zJWlE9fahyj6vod9PrGEdjcrHgKiwxRpopAf99Yfa8HrTm G57ANxALMRtwvXkL073LL3Y/GtLuY0/JyToFlZ6ZlZfvb7LjqRA9oXlPHeVglXLZ hcxxtHo+HkLkVPFQCcOujSYTuyTvKlMHjpTa3LUBjJV+gQf9xjrZku7BOiPg== X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p4.oit.umn.edu ([127.0.0.1]) by localhost (mta-p4.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9PIibCpnM61z for ; Fri, 19 Apr 2019 22:08:45 -0500 (CDT) Received: from mail-it1-f179.google.com (mail-it1-f179.google.com [209.85.166.179]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: wang6495) by mta-p4.oit.umn.edu (Postfix) with ESMTPSA id 2873FA31 for ; Fri, 19 Apr 2019 22:08:45 -0500 (CDT) Received: by mail-it1-f179.google.com with SMTP id a190so10884168ite.4 for ; Fri, 19 Apr 2019 20:08:45 -0700 (PDT) X-Gm-Message-State: APjAAAXRalVBRtY9LuCw7OPzkXtp/YI6xuR55eVuT0isSp2LTzmIXZvN Bx8uv3eqELxEUmYGtoCIM+uAj1sdsrzmYEzUYxs= X-Received: by 2002:a02:1006:: with SMTP id 6mr5267131jay.47.1555729724961; Fri, 19 Apr 2019 20:08:44 -0700 (PDT) MIME-Version: 1.0 References: <1555726979-15633-1-git-send-email-wang6495@umn.edu> <20190419223718.17fa8246@oasis.local.home> In-Reply-To: <20190419223718.17fa8246@oasis.local.home> From: Wenwen Wang Date: Fri, 19 Apr 2019 22:08:08 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] tracing: Fix a memory leak bug To: Steven Rostedt Cc: Ingo Molnar , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 19, 2019 at 9:37 PM Steven Rostedt wrote: > > On Fri, 19 Apr 2019 21:22:59 -0500 > Wenwen Wang wrote: > > > In trace_pid_write(), the buffer for trace parser is allocated through > > kmalloc() in trace_parser_get_init(). Later on, after the buffer is used, > > it is then freed through kfree() in trace_parser_put(). However, it is > > possible that trace_pid_write() is terminated due to unexpected errors, > > e.g., ENOMEM. In that case, the allocated buffer will not be freed, which > > is a memory leak bug. > > > > To fix this issue, free the allocated buffer when an error is encountered. > > Thanks for the patch. Did you find this through manual inspection, > running KASAN or via one of the static analyzers? Thanks for your question, Steve. It was based on a prototype of a research project, which aims to statically detect memory leak bugs in operating system kernels. Wenwen