From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24859241C8C; Sat, 30 May 2026 18:15:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780164913; cv=none; b=eHKIhb6lDL7woIrY5FQEVk/jc5OqmY3XrQu4ELsX9amyO9mh8wzaCWRqk1lOV3tgIbsD7o1VCuDMMWGnUTC9hFoFAC7TA5zMWIA+rT9s/5jrAitgxsspTTQ2Tp2qi5gtG7H+qqFBkQ2Rmy8oqijK5S29GT2NNc3/sVmPRIyQKN4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780164913; c=relaxed/simple; bh=Sl2ZVW5Y7DHe1WnEKCwgd5k7IlRmfS5H5JCd2wtg6k0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YZ8tGBb9+RxKUbtsYC6cwTJtb1YplR8hziQnUzIvdS5lGweC4ZFdb9jgYcX1VdBcl0YjM+GuHKTLrsxa6NIWQtDnNN+S8Eft5huJw6dF+swosCxlMQXw4V1UZUuDWluWI4mttZeQ0lHPEmDUVoL1AO/mQm1PEZuInsrmMKGB/+4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=D1gDmvIL; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="D1gDmvIL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AB371F00893; Sat, 30 May 2026 18:15:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780164912; bh=0/NZRyUpSDMFqkF3LlNsxzdK55iGI4eMnn5rbFCbfOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=D1gDmvILP7+VsB3noTjLJjAWuNGz+SOyBVRG7ZI9LqDBattyD2My4Ddpt9svBlTM1 IW8mEt6N63SbimzgUhvAeapjluGKFhCcHBfKKPmmB2fUhZKjCBf/JNxb/5x/bgXrCQ FgE4fjddHFoX4KWxmlnq+wurgIiMuIIfkoicvYWo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tom Zanussi , Mathieu Desnoyers , Rosen Penev , Sashiko , "Masami Hiramatsu (Google)" , Steven Rostedt Subject: [PATCH 5.15 696/776] tracing: Do not call map->ops->elt_free() if elt_alloc() fails Date: Sat, 30 May 2026 18:06:50 +0200 Message-ID: <20260530160257.822013326@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160240.228940103@linuxfoundation.org> References: <20260530160240.228940103@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Masami Hiramatsu (Google) commit 8f0f5c4fb9df0e19a341e0c6ed8dc4fda9124f03 upstream. In paths where tracing_map_elt_alloc() failed to allocate objects, the map->ops->elt_alloc() call was never successful. In this case, map->ops->elt_free() should not be called. Link: https://sashiko.dev/#/patchset/20260520223101.34710-1-rosenp%40gmail.com Cc: stable@vger.kernel.org Cc: Tom Zanussi Cc: Mathieu Desnoyers Cc: Rosen Penev Reported-by: Sashiko Fixes: 2734b629525a ("tracing: Add per-element variable support to tracing_map") Link: https://patch.msgid.link/177933895460.108746.5396070821443932634.stgit@devnote2 Signed-off-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt Signed-off-by: Greg Kroah-Hartman --- kernel/trace/tracing_map.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) --- a/kernel/trace/tracing_map.c +++ b/kernel/trace/tracing_map.c @@ -386,13 +386,11 @@ static void tracing_map_elt_init_fields( } } -static void tracing_map_elt_free(struct tracing_map_elt *elt) +static void __tracing_map_elt_free(struct tracing_map_elt *elt) { if (!elt) return; - if (elt->map->ops && elt->map->ops->elt_free) - elt->map->ops->elt_free(elt); kfree(elt->fields); kfree(elt->vars); kfree(elt->var_set); @@ -400,6 +398,17 @@ static void tracing_map_elt_free(struct kfree(elt); } +static void tracing_map_elt_free(struct tracing_map_elt *elt) +{ + if (!elt) + return; + + /* Only objects initialized with alloc_elt() should be passed to free_elt().*/ + if (elt->map->ops && elt->map->ops->elt_free) + elt->map->ops->elt_free(elt); + __tracing_map_elt_free(elt); +} + static struct tracing_map_elt *tracing_map_elt_alloc(struct tracing_map *map) { struct tracing_map_elt *elt; @@ -444,7 +453,7 @@ static struct tracing_map_elt *tracing_m } return elt; free: - tracing_map_elt_free(elt); + __tracing_map_elt_free(elt); return ERR_PTR(err); }