* [PATCH] Guard against inserting the same provider twice
@ 2026-01-15 22:22 eugene.loh
2026-01-15 22:56 ` Kris Van Hees
0 siblings, 1 reply; 2+ messages in thread
From: eugene.loh @ 2026-01-15 22:22 UTC (permalink / raw)
To: dtrace, dtrace-devel
From: Eugene Loh <eugene.loh@oracle.com>
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 <eugene.loh@oracle.com>
---
libdtrace/dt_provider.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libdtrace/dt_provider.c b/libdtrace/dt_provider.c
index 848fdc132..9d75225fa 100644
--- a/libdtrace/dt_provider.c
+++ b/libdtrace/dt_provider.c
@@ -114,6 +114,8 @@ dt_provider_lookup(dtrace_hdl_t *dtp, const char *name)
return NULL;
strcpy(tmpl.desc.dtvd_name, name);
+ if (dtp->dt_provs == NULL)
+ return NULL;
return dt_htab_lookup(dtp->dt_provs, &tmpl);
}
@@ -124,6 +126,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;
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Guard against inserting the same provider twice
2026-01-15 22:22 [PATCH] Guard against inserting the same provider twice eugene.loh
@ 2026-01-15 22:56 ` Kris Van Hees
0 siblings, 0 replies; 2+ messages in thread
From: Kris Van Hees @ 2026-01-15 22:56 UTC (permalink / raw)
To: eugene.loh; +Cc: dtrace, dtrace-devel
Minor nit below...
On Thu, Jan 15, 2026 at 05:22:51PM -0500, eugene.loh@oracle.com wrote:
> From: Eugene Loh <eugene.loh@oracle.com>
>
> 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 <eugene.loh@oracle.com>
> ---
> libdtrace/dt_provider.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/libdtrace/dt_provider.c b/libdtrace/dt_provider.c
> index 848fdc132..9d75225fa 100644
> --- a/libdtrace/dt_provider.c
> +++ b/libdtrace/dt_provider.c
> @@ -114,6 +114,8 @@ dt_provider_lookup(dtrace_hdl_t *dtp, const char *name)
> return NULL;
>
> strcpy(tmpl.desc.dtvd_name, name);
> + if (dtp->dt_provs == NULL)
> + return NULL;
This should be moved as the first conditional in the function, because we
want to return immediately if there is no dtp->dt_provs yet.
> return dt_htab_lookup(dtp->dt_provs, &tmpl);
> }
>
> @@ -124,6 +126,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;
>
> --
> 2.47.3
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-15 22:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-15 22:22 [PATCH] Guard against inserting the same provider twice eugene.loh
2026-01-15 22:56 ` Kris Van Hees
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox