Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp174187lqa; Fri, 26 Apr 2024 19:58:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXl1uL+7nymWROmNNxl5CHPJ5sHHv5rHE84oij/b7VuuCw0pCh1j/rIBDDFasrv7bEnosrANiJncuUOZ5nALlwsw3AbXcoMz2RIF/DlXg== X-Google-Smtp-Source: AGHT+IHT0wZbGC2zKLEWiV8ugx405tu7B5VuILJvisvr2PCrsAUYrak45PDFlj/tjwEzxyxUUcS/ X-Received: by 2002:a17:90a:134c:b0:2ad:9382:35be with SMTP id y12-20020a17090a134c00b002ad938235bemr6182727pjf.16.1714186698468; Fri, 26 Apr 2024 19:58:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714186698; cv=pass; d=google.com; s=arc-20160816; b=o8RBTKVNWZtTpETc6xuXExwNGEcHrXVIdgcYcXF4p6tNlEoycX6iJOM6y7lHpwsYi0 EYQ3pRRyP58c2t/PnzbghqGRYiwScb3oxW/DwqhkZuHIxiuGvmnysuMwNCeNgi/AtEM5 qL9i0M4ULmlEkr7CFRyamoT4EeZNMlZtcM4hPanAdny3EbdpwfXYGq2beKsM+U1oEaw7 kEXA8kbInrLZqnCjzmUPzC15ba6TVzABzCmmpJIh9UH6Gcyh+t8hkJGuoN6DgxjnPknm tw4hWgUCxLlz5ScPpTWTQq3oPvwCi8T29Si6LqDtwiMddkGS/vznCT7dv87wxyUPc34I TNTg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=fy6C0g0qKGiiSklD9pwp4zCj85V4AWoPTjeoUY/osls=; fh=7AISyinBPoGk2o6fUPu5txctBKhc7h52QNgYxqjoWO4=; b=hX9QqZk5JEL8QMoa/NeZ6K5oUWXUhiH993ru8hUbwuJM69GkgQpKl/RkFAmz6dSTu7 3iuCGg8Yii0h2sK3+p7fx1zqhGI5ouicjYR891qapq0F+/G8syXKxZGaWPx/1CDNE2xP Ly7R8MgaER6hksIHMghCIQoOP147EnfuEtsdhG0Utt+bP/kiaVsI8zTVCwJOO7ZI5HrR nsWk8jquwbSXxTBIK9HI+bh77SsPhDxIk4FNUYJNfS78+rrAQ9gvicsPZbHnfw+4GO3F fbTashfZA2k/mOMzvP7LAbT6s0mUPG3iLDAxOoP9fsyMVv8QIDqVDUd1UI9xYGclV9KJ WXCA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b="BoP/sU4R"; arc=pass (i=1 spf=pass spfdomain=126.com dkim=pass dkdomain=126.com dmarc=pass fromdomain=126.com); spf=pass (google.com: domain of linux-kernel+bounces-160874-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160874-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y19-20020a17090aa41300b002ae0a2c291dsi9679717pjp.71.2024.04.26.19.58.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 19:58:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160874-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b="BoP/sU4R"; arc=pass (i=1 spf=pass spfdomain=126.com dkim=pass dkdomain=126.com dmarc=pass fromdomain=126.com); spf=pass (google.com: domain of linux-kernel+bounces-160874-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160874-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0AEA828396B for ; Sat, 27 Apr 2024 02:58:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E39CF3BB3D; Sat, 27 Apr 2024 02:58:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.b="BoP/sU4R" Received: from m16.mail.126.com (m16.mail.126.com [220.197.31.9]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 832EC33C8; Sat, 27 Apr 2024 02:58:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714186686; cv=none; b=AiJf0vUzx8r4gGbzRNinSnWXk3o+gURVvmhLu2Os8DUR/1uWGPvufdD5gVGUx/Jt2OWawxkfxJzK7VYGN1FH+kGT4UpGYh3A0UJ8j7wqRWi/xDjxv+RBkbRYvXyHMKzYq4FAhk5ZlFoPLIutwONZ0SMs3VJEbb9Eh8wHdsBnxSs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714186686; c=relaxed/simple; bh=xX5D+EAZ5Bpq4vJHf+wbm1BIbRo+WTB8OkrJBGaP538=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=CqLqGbV4ZDP0XLTNZrprr0AbelLEujfgmmcmDe0lBTYS13rbjymrntPmCisx0FvJ7Rd5ImdavNy/V4zW+372kr9IiM3ZdouTX3XcMlXENEUY4u4IjoHbKykBqPAO0y5zonIsHl8B161ZRhi/2Ib1FOiloFlIrG4WJfmaVrxAsE4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com; spf=pass smtp.mailfrom=126.com; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.b=BoP/sU4R; arc=none smtp.client-ip=220.197.31.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=126.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=fy6C0 g0qKGiiSklD9pwp4zCj85V4AWoPTjeoUY/osls=; b=BoP/sU4RpTOWtH/KEjmBt g57CBLUt2c4DSk1iP6y7chyxkX4gbzvdBcw2jXwAjLF0NIkSLIlVXvcgzKDdlwaU 33NA4UojRde44TqnVE2JThjNWcAEyi497IecKTjSTpMpHy39m6+KwLOI2qwAesMo cP+OrcsInxt6mY4YZX+5x0= Received: from localhost.localdomain (unknown [111.198.54.11]) by gzga-smtp-mta-g1-2 (Coremail) with SMTP id _____wD3X1CSaSxmFuefBA--.58122S2; Sat, 27 Apr 2024 10:57:23 +0800 (CST) From: lumingyindetect@126.com To: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, LuMingYin Subject: [PATCH v2] tracing/probes: Fix memory leak in traceprobe_parse_probe_arg_body Date: Sat, 27 Apr 2024 03:57:20 +0100 Message-Id: <20240427025720.1321211-1-lumingyindetect@126.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wD3X1CSaSxmFuefBA--.58122S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7Wr1fXr18uFWfJFyfWw17Wrg_yoWDXFcEka ykGa4kXr4jkrsrurW3ArsaqrWq9F1rWFy09a17tFZ8J34jkr13W3Z8CasYqrZ5WFyqqr97 XwnxWr1v9FyrKjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU017K7UUUUU== X-CM-SenderInfo: poxpx0hj1l0vphwhu3a6rslhhfrp/1tbiEBzM9mVLbFus-AACs9 From: LuMingYin If traceprobe_parse_probe_arg_body() fails to allocate 'parg->fmt', it jumps to 'out' instead of 'fail' by mistake. In the result, in this case the 'tmp' buffer is not freed and leaks its memory. Fix it by jumping to 'fail' in that case. Fixes: 032330abd08b ("tracing/probes: Cleanup probe argument parser") Signed-off-by: LuMingYin --- kernel/trace/trace_probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index dfe3ee6035ec..42bc0f362226 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -1466,7 +1466,7 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size, parg->fmt = kmalloc(len, GFP_KERNEL); if (!parg->fmt) { ret = -ENOMEM; - goto out; + goto fail; } snprintf(parg->fmt, len, "%s[%d]", parg->type->fmttype, parg->count); -- 2.25.1