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 43966C54EAA for ; Mon, 30 Jan 2023 15:20:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237965AbjA3PUO (ORCPT ); Mon, 30 Jan 2023 10:20:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238209AbjA3PUC (ORCPT ); Mon, 30 Jan 2023 10:20:02 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82E4238648; Mon, 30 Jan 2023 07:19:52 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 37814B81185; Mon, 30 Jan 2023 15:19:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 150FDC433D2; Mon, 30 Jan 2023 15:19:48 +0000 (UTC) Date: Mon, 30 Jan 2023 10:19:47 -0500 From: Steven Rostedt To: Pietro Borrello Cc: Masami Hiramatsu , Cristiano Giuffrida , "Bos, H.J." , Jakob Koschel , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: Re: [PATCH] tracing/probe: trace_probe_primary_from_call(): checked list_first_entry Message-ID: <20230130101947.311010c2@gandalf.local.home> In-Reply-To: <20230128-list-entry-null-check-v1-1-8bde6a3da2ef@diag.uniroma1.it> References: <20230128-list-entry-null-check-v1-1-8bde6a3da2ef@diag.uniroma1.it> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 28 Jan 2023 16:23:41 +0000 Pietro Borrello wrote: > All callers of trace_probe_primary_from_call() check the return > value to be non NULL. However, the function returns > list_first_entry(&tpe->probes, ...) which can never be NULL. > Additionally, it does not check for the list being possibly empty, > possibly causing a type confusion on empty lists. > Use list_first_entry_or_null() which solves both problems. > > Fixes: 60d53e2c3b75 ("tracing/probe: Split trace_event related data from trace_probe") > Signed-off-by: Pietro Borrello > --- > kernel/trace/trace_probe.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h > index 23acfd1c3812..f6b565dced56 100644 > --- a/kernel/trace/trace_probe.h > +++ b/kernel/trace/trace_probe.h > @@ -307,7 +307,7 @@ trace_probe_primary_from_call(struct trace_event_call *call) > { > struct trace_probe_event *tpe = trace_probe_event_from_call(call); > > - return list_first_entry(&tpe->probes, struct trace_probe, list); > + return list_first_entry_or_null(&tpe->probes, struct trace_probe, list); > } > > static inline struct list_head *trace_probe_probe_list(struct trace_probe *tp) Reviewed-by: Steven Rostedt (Google) -- Steve > > --- > base-commit: 2241ab53cbb5cdb08a6b2d4688feb13971058f65 > change-id: 20230128-list-entry-null-check-37778efda18c > > Best regards,