Skip to content

Commit b0ef4fe

Browse files
committed
Checking pid_tgid earlier so if inode is null we still cleanup
1 parent 2974373 commit b0ef4fe

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

fact-ebpf/src/bpf/main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,19 +294,19 @@ int BPF_PROG(trace_d_instantiate, struct dentry* dentry, struct inode* inode) {
294294

295295
m->d_instantiate.total++;
296296

297-
if (inode == NULL) {
298-
m->d_instantiate.ignored++;
299-
return 0;
300-
}
301-
302297
__u64 pid_tgid = bpf_get_current_pid_tgid();
303298
struct mkdir_context_t* mkdir_ctx = bpf_map_lookup_elem(&mkdir_context, &pid_tgid);
299+
304300
if (mkdir_ctx == NULL) {
305301
m->d_instantiate.ignored++;
306302
return 0;
307303
}
308304

309-
// From this point on, we must clean up mkdir_context before returning
305+
if (inode == NULL) {
306+
m->d_instantiate.ignored++;
307+
goto cleanup;
308+
}
309+
310310
umode_t mode = BPF_CORE_READ(inode, i_mode);
311311
if (!S_ISDIR(mode)) {
312312
m->d_instantiate.ignored++;

0 commit comments

Comments
 (0)