[DTrace-devel] [PATCH] Avoid out-of-memory error report when linking BPF code without relocs
Kris Van Hees
kris.van.hees at oracle.com
Wed Jun 24 08:30:43 PDT 2020
When there are no BPF relocation records, an allocation of size 0 was
being attempted. Since that resulted in a NULL return value, it was
assumed that the allocation failure indicated an out-of-memory
condition.
We now simply do not try to allocate a BPF relocation table when there
are no BPF relocation records to be copied into it.
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
libdtrace/dt_cc.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/libdtrace/dt_cc.c b/libdtrace/dt_cc.c
index 67834790..d6a78166 100644
--- a/libdtrace/dt_cc.c
+++ b/libdtrace/dt_cc.c
@@ -2365,9 +2365,12 @@ dt_link_stmt(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, dtrace_stmtdesc_t *sdp,
if (fdp->dtdo_buf == NULL)
goto nomem;
fdp->dtdo_len = insc;
- fdp->dtdo_breltab = dt_calloc(dtp, relc, sizeof(dof_relodesc_t));
- if (fdp->dtdo_breltab == NULL)
- goto nomem;
+ if (relc) {
+ fdp->dtdo_breltab = dt_calloc(dtp, relc,
+ sizeof(dof_relodesc_t));
+ if (fdp->dtdo_breltab == NULL)
+ goto nomem;
+ }
fdp->dtdo_brelen = relc;
/*
--
2.26.0
More information about the DTrace-devel
mailing list