Message ID | 20221115014445.158419-1-xiujianfeng@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2466445wru; Mon, 14 Nov 2022 17:51:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf47eQvnYd8iYWDKMdf0QwVvvWCVfSn0Psvbz6QaPJ9/5kAs8/OUlGAB74Dkt1rAnn2RVakU X-Received: by 2002:aa7:c74c:0:b0:44e:bee5:4242 with SMTP id c12-20020aa7c74c000000b0044ebee54242mr13224461eds.128.1668477099128; Mon, 14 Nov 2022 17:51:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668477099; cv=none; d=google.com; s=arc-20160816; b=aJGOkdMw5fa5JzHgBuEdpoSMl5D80un8g34mOqD/cJfizwp+rnOK4U0LgrI5BI0NA4 S4bka6fFsuzo/5wjPrEpbZeNhtl1IXk6pYytnG3D4v8cf90WRJSvxL72DV5GMaGtxFKj j4FSSaLZoYjkwr7GfNEaM7LAIcCSRe2bbkiU0aGI9ioY39GWankJanq7kQ9pw2TYhq/g k0M621rBuVkFTzg6cvOkbSya0m18ldmXG0AKZM697QgUNVbR/8rUf6F35VU/PX5675pV MVf8mPXPTZq/iEZ7h8fcv8Axwy0tMkcH7E5sZmbVCIqPsj93IeIYwUv0eHL5VexOfKi5 uisg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=56lWGaARTCDZ3tp7on+E+xtfyqwkCY+tMI8idzXgGR4=; b=Jz58cYGT2EJCvh07WYAryEGL0riYG8rR559z/ID8gcD9OJzypDBvGoTIZKm2k4WqkK ow/XlMOtkLii0WCyyYaP3jRMPgQRdF5s+vIQw7oZea3jtlsd05bSvqNb32To/DRJyzLJ 6Imo0GvI3m4psZPYCkUylXH4DuOhxRDJZ99MLIlGYRdg9+0YTHMRY+4qWZyBNAZNs+Ia wOXKXEb339dYOUurzcgK4bDWzspJWDLsfiTb7jGsarCEc1nMsFz06HV1joxzIBy2vmNv laWdhRlTn+QJUTJi5ltoIG8V33ctXuDcR7hS87I5DD2Wua6M0YHGMcSIliYrJkgIxxN6 v0Hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g18-20020a170906349200b007ad976163f4si8587656ejb.254.2022.11.14.17.51.15; Mon, 14 Nov 2022 17:51:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232164AbiKOBr6 (ORCPT <rfc822;zwp10758@gmail.com> + 99 others); Mon, 14 Nov 2022 20:47:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229691AbiKOBr4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 14 Nov 2022 20:47:56 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81D1317421 for <linux-kernel@vger.kernel.org>; Mon, 14 Nov 2022 17:47:55 -0800 (PST) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NB8F80DcdzHvtb; Tue, 15 Nov 2022 09:47:24 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.58) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 15 Nov 2022 09:47:53 +0800 From: Xiu Jianfeng <xiujianfeng@huawei.com> To: <rostedt@goodmis.org>, <mhiramat@kernel.org>, <beaub@linux.microsoft.com> CC: <linux-kernel@vger.kernel.org> Subject: [PATCH] tracing/user_events: Fix memory leak in user_event_create() Date: Tue, 15 Nov 2022 09:44:45 +0800 Message-ID: <20221115014445.158419-1-xiujianfeng@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.58] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500023.china.huawei.com (7.185.36.114) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749525042836689876?= X-GMAIL-MSGID: =?utf-8?q?1749525042836689876?= |
Series |
tracing/user_events: Fix memory leak in user_event_create()
|
|
Commit Message
Xiu Jianfeng
Nov. 15, 2022, 1:44 a.m. UTC
Before current_user_event_group(), it has allocated memory and save it
in @name, this should freed before return error.
Fixes: e5d271812e7a ("tracing/user_events: Move pages/locks into groups to prepare for namespaces")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
kernel/trace/trace_events_user.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Tue, 15 Nov 2022 09:44:45 +0800 Xiu Jianfeng <xiujianfeng@huawei.com> wrote: > Before current_user_event_group(), it has allocated memory and save it > in @name, this should freed before return error. > > Fixes: e5d271812e7a ("tracing/user_events: Move pages/locks into groups to prepare for namespaces") > Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> This looks good to me. Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Thanks, > --- > kernel/trace/trace_events_user.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c > index ae78c2d53c8a..539b08ae7020 100644 > --- a/kernel/trace/trace_events_user.c > +++ b/kernel/trace/trace_events_user.c > @@ -1100,8 +1100,10 @@ static int user_event_create(const char *raw_command) > > group = current_user_event_group(); > > - if (!group) > + if (!group) { > + kfree(name); > return -ENOENT; > + } > > mutex_lock(&group->reg_mutex); > > -- > 2.17.1 >
On Wed, Nov 16, 2022 at 12:07:17AM +0900, Masami Hiramatsu wrote: > On Tue, 15 Nov 2022 09:44:45 +0800 > Xiu Jianfeng <xiujianfeng@huawei.com> wrote: > > > Before current_user_event_group(), it has allocated memory and save it > > in @name, this should freed before return error. > > Nice catch! Acked-by: Beau Belgrave <beaub@linux.microsoft.com> Thanks, -Beau > > Fixes: e5d271812e7a ("tracing/user_events: Move pages/locks into groups to prepare for namespaces") > > Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> > > This looks good to me. > > Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> > > Thanks, > > > --- > > kernel/trace/trace_events_user.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c > > index ae78c2d53c8a..539b08ae7020 100644 > > --- a/kernel/trace/trace_events_user.c > > +++ b/kernel/trace/trace_events_user.c > > @@ -1100,8 +1100,10 @@ static int user_event_create(const char *raw_command) > > > > group = current_user_event_group(); > > > > - if (!group) > > + if (!group) { > > + kfree(name); > > return -ENOENT; > > + } > > > > mutex_lock(&group->reg_mutex); > > > > -- > > 2.17.1 > > > > > -- > Masami Hiramatsu (Google) <mhiramat@kernel.org>
diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index ae78c2d53c8a..539b08ae7020 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -1100,8 +1100,10 @@ static int user_event_create(const char *raw_command) group = current_user_event_group(); - if (!group) + if (!group) { + kfree(name); return -ENOENT; + } mutex_lock(&group->reg_mutex);