Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6340203rwb; Mon, 14 Nov 2022 18:55:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf4TXBzQvN/ftgb9/ej0AGV0MS2DSj3Khra69ZcJehThspYzPaqFlysBxMOFRymySlksWa+Y X-Received: by 2002:aa7:db46:0:b0:459:278b:7a8b with SMTP id n6-20020aa7db46000000b00459278b7a8bmr13044176edt.355.1668480907127; Mon, 14 Nov 2022 18:55:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668480907; cv=none; d=google.com; s=arc-20160816; b=kXyzAimOq0nLy+DhQY1tZ5D7vv4VZAYzbBU0X1ftmoyWDnIBk3N/DQqUehDmGP4r/K aDWhDxTLFA9OCX8hsEzRInX6emt3PUgRPIPTCWrppUTWpcizlF40NyY1EImJsfol+Lif QpLkaMJiKtayPVmquTCc6q0jZX92Dt4QAdgTW2EMXdd6EoMT4gNkNcD4/2Ja/6qD1JMY gjB4uBWwawBKRaZy2fUN+yBooEllXRuSkNZMGKUZdYd1AaPpLC26KLnuM+DafQKrlYRK bMnd3bRD6JrLoI8AYHuWxZdHEPRxaLrklj3ULVkAdgvMpTRa/fXtylN/R3q7fVPNf8t5 qSLw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw32-20020a1709066a2000b007a20c586f4esi10699986ejc.876.2022.11.14.18.54.42; Mon, 14 Nov 2022 18:55:07 -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 + 88 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 ); 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 ; 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 To: , , CC: 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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