Guard against inserting the same provider twice
PATCH v2 1/1 Guard against inserting the same provider twice
From: Eugene Loh <[email protected]>
Add a safety net to dt_provider_create(), to check if a specified provider has already been inserted.
This also requires a corresponding change in dt_provider_lookup(), so that it will work even if no providers have yet been inserted.
Signed-off-by Eugene Loh <[email protected]>
--- libdtrace/dt_provider.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
libdtrace/dt_provider.c +8 -1
@@ -1,6 +1,6 @@/* * Oracle Linux DTrace. -* Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2006, 2026, Oracle and/or its affiliates. All rights reserved. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */
@@ -110,6 +110,9 @@ dt_provider_lookup(dtrace_hdl_t *dtp, const char *name) {dt_provider_t tmpl; +if (dtp->dt_provs ==NULL ) +return NULL ; +if ((strlen (name) +1 ) >sizeof (tmpl.desc.dtvd_name))return NULL ;
@@ -124,6 +127,10 @@ dt_provider_create(dtrace_hdl_t *dtp, const char *name, {dt_provider_t *pvp; + pvp =dt_provider_lookup (dtp, name); +if (pvp) +return pvp; +if ((pvp =dt_zalloc (dtp,sizeof (dt_provider_t))) ==NULL ) goto nomem;
Signature · 1 line
2.47.3
Quoted 9 lines · On Fri, Jan 16, 2026 at 03:38:12PM -0500, [email protected] wrote:
From: Eugene Loh <[email protected]>
Add a safety net to
dt_provider_create(), to check if a specified provider has already been inserted.This also requires a corresponding change in
dt_provider_lookup(), so that it will work even if no providers have yet been inserted.Signed-off-by Eugene Loh <[email protected]>
Reviewed-by Kris Van Hees <[email protected]>
Quoted 40 lines
--- libdtrace/dt_provider.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)libdtrace/dt_provider.c +8
-1@@ -1,6 +1,6 @@/* * Oracle Linux DTrace. -* Copyright (c) 2006, 2025, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2006, 2026, Oracle and/or its affiliates. All rights reserved. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -110,6 +110,9 @@ dt_provider_lookup(dtrace_hdl_t *dtp, const char *name) {dt_provider_t tmpl; +if (dtp->dt_provs ==NULL ) +return NULL ; +if ((strlen (name) +1 ) >sizeof (tmpl.desc.dtvd_name))return NULL ;@@ -124,6 +127,10 @@ dt_provider_create(dtrace_hdl_t *dtp, const char *name, {dt_provider_t *pvp; + pvp =dt_provider_lookup (dtp, name); +if (pvp) +return pvp; +if ((pvp =dt_zalloc (dtp,sizeof (dt_provider_t))) ==NULL ) goto nomem;Signature · 1 line
2.47.3