Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2025670pxa; Mon, 3 Aug 2020 05:42:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzOaLCaOPEWYEUB2uwXZssaS1dLKldtH3Gh0bi6XLQ3Lpbd+Mfv68v0GzDMdFsWIn3BpJd X-Received: by 2002:a50:e846:: with SMTP id k6mr1280637edn.27.1596458576475; Mon, 03 Aug 2020 05:42:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596458576; cv=none; d=google.com; s=arc-20160816; b=WFcs/6yXvOQBoFMUuipo11wIWmuWnDR4QINOf0ZGjigd9asx9evdX6caaxl6Uo3Sp0 CPWFMbcGcpsanHPf+AvWsJX9D05R7H64KcwQKBOAri9CZawLYzdjqOWCF1yiffI1Ww0J b5/XB+YBOuilh2kVwX4i7IDDlFoQSTeWjob7yWxpvquGrDDyHx/cjgadCjFAwM3klTZs pupgBGgULV4HRyEjiQj/I9HeujYaBq33GTtRNEYgQB36KeHIk83JeB7rC7O/XQeQhBc7 ueh8fQAGOnKIRmN7reixCRRkJGf9Fqls/PVLWovdarjwdufF+GFRfMu+4+OHkrI/wsRq g+wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6lwN4qeUggqJIKzr2OZqRQq4GTT/L4aoKFoSfTehufo=; b=jNWjmyoLY81v11UUj8sMRSKmiOgbllATr8gDdofkIcVtbF8Y9VxGJELKLQqWcoSEei S6giTWNe3b03KG/yvOPKvHrbseHW1YsSxwe1mjAbnlHU80QXN6c9U78prapv29lFWB6V C0YwEF5Ik/uHuumSgN2faVoHOkgWbzPVAieEBt7O93bzlBNaUP7EInorwCc69pAWjrz8 gbvvp8onN+2Yr5ddPrKLpNH9cJbxbR+3nabrGvkFaAoVE/Y1cSQFnCPbSlrpCtbnUIhE 6LxeZlpDZIRtfmyg+KHKhxXmucahhAGhP4KxWW0IcwWAnjkwawCVIoiGKapm+5UHKl2u 7KyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Qq+s4C6v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k21si295962eje.480.2020.08.03.05.42.33; Mon, 03 Aug 2020 05:42:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Qq+s4C6v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728185AbgHCMbs (ORCPT + 99 others); Mon, 3 Aug 2020 08:31:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:59498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729224AbgHCMbq (ORCPT ); Mon, 3 Aug 2020 08:31:46 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E80EF208E4; Mon, 3 Aug 2020 12:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596457905; bh=Hy8mBhV7h9SLwvg7GqfwObL1tL77wSLQh01A/CTIrhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qq+s4C6vfk0jeZhnLAkglojCP564gH8MRuQyRgEY4eEANy6j5z+K2GdYG+yCiN/JW bJQx9TGnwpFc1uvnQwDPDpvfftHHUWtdK5+wyOVL10M76AzndC1oM2lBw2CT/skMGI /oYKwo1toVMtksa5Jc294nfTTgoutqTiRfA3xjxA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Navid Emamdoost , "Steven Rostedt (VMware)" , Sasha Levin Subject: [PATCH 4.19 05/56] tracing: Have error path in predicate_parse() free its allocated memory Date: Mon, 3 Aug 2020 14:19:20 +0200 Message-Id: <20200803121850.577138860@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200803121850.306734207@linuxfoundation.org> References: <20200803121850.306734207@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Navid Emamdoost [ Upstream commit 96c5c6e6a5b6db592acae039fed54b5c8844cd35 ] In predicate_parse, there is an error path that is not going to out_free instead it returns directly which leads to a memory leak. Link: http://lkml.kernel.org/r/20190920225800.3870-1-navid.emamdoost@gmail.com Signed-off-by: Navid Emamdoost Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Sasha Levin --- kernel/trace/trace_events_filter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index b949c3917c679..9be3d1d1fcb47 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c @@ -451,8 +451,10 @@ predicate_parse(const char *str, int nr_parens, int nr_preds, switch (*next) { case '(': /* #2 */ - if (top - op_stack > nr_parens) - return ERR_PTR(-EINVAL); + if (top - op_stack > nr_parens) { + ret = -EINVAL; + goto out_free; + } *(++top) = invert; continue; case '!': /* #3 */ -- 2.25.1