From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C43CC433FE for ; Tue, 15 Nov 2022 17:07:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230376AbiKORHr (ORCPT ); Tue, 15 Nov 2022 12:07:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229877AbiKORHn (ORCPT ); Tue, 15 Nov 2022 12:07:43 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DDCF3D77 for ; Tue, 15 Nov 2022 09:07:42 -0800 (PST) Received: from kbox (unknown [76.135.50.127]) by linux.microsoft.com (Postfix) with ESMTPSA id 89F7020B717A; Tue, 15 Nov 2022 09:07:42 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 89F7020B717A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1668532062; bh=HrunAVDEDm+yyiX3Yrk2zJt4p2vGEeG8d0hq/GRhpwY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EKZTb0FqpRT9LHP5yW1FbduWK9uCd/imA3SR+R48ODOBYSadn6CmE5oeUbNW/44cM FNAw5lDUWmTivEToNzYo4sKlQ9ENtjn+ROr/Kn2xejJ+JYkt2TcSf3llaRKiHEMJB+ yN1Lc9a+CxubHQXHVrwgYuRhfMdrt98LhZ2yUp3M= Date: Tue, 15 Nov 2022 09:07:35 -0800 From: Beau Belgrave To: Masami Hiramatsu Cc: Xiu Jianfeng , rostedt@goodmis.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] tracing/user_events: Fix memory leak in user_event_create() Message-ID: <20221115170735.GA1794@kbox> References: <20221115014445.158419-1-xiujianfeng@huawei.com> <20221116000717.4b62513eeaf0b2296b399bda@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221116000717.4b62513eeaf0b2296b399bda@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 16, 2022 at 12:07:17AM +0900, Masami Hiramatsu wrote: > On Tue, 15 Nov 2022 09:44:45 +0800 > Xiu Jianfeng 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 Thanks, -Beau > > Fixes: e5d271812e7a ("tracing/user_events: Move pages/locks into groups to prepare for namespaces") > > Signed-off-by: Xiu Jianfeng > > This looks good to me. > > Acked-by: Masami Hiramatsu (Google) > > 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)