extern void dtrace_enable(void);
extern void dtrace_disable(void);
-extern void dtrace_invop_add(uint8_t (*func)(struct pt_regs *));
+extern int dtrace_invop_add(uint8_t (*func)(struct pt_regs *));
extern void dtrace_invop_remove(uint8_t (*func)(struct pt_regs *));
extern void dtrace_invop_enable(uint8_t *);
struct mm_struct *mm;
psinfo = kzalloc(sizeof(dtrace_psinfo_t), GFP_KERNEL);
- if (psinfo == NULL) {
- pr_warning("%s: cannot allocate DTrace psinfo structure\n",
- __func__);
- return NULL;
- }
+ if (psinfo == NULL)
+ goto fail;
mm = get_task_mm(task);
if (mm) {
}
psinfo->argv = vmalloc((psinfo->argc + 1) * sizeof(char *));
+ if (psinfo->argv == NULL)
+ goto fail;
/*
* Now populate the array of argument strings.
}
psinfo->envp = vmalloc((envc + 1) * sizeof(char *));
+ if (psinfo->envp == NULL)
+ goto fail;
/*
* Now populate the array of environment variable strings.
}
return psinfo;
+
+fail:
+ pr_warning("%s: cannot allocate DTrace psinfo structure\n", __func__);
+ if (psinfo) {
+ if (psinfo->argv == NULL)
+ vfree(psinfo->argv);
+ if (psinfo->envp == NULL)
+ vfree(psinfo->envp);
+
+ kfree(psinfo);
+ }
+
+ return NULL;
}
static DEFINE_SPINLOCK(psinfo_lock);
}
EXPORT_SYMBOL(dtrace_disable);
-void dtrace_invop_add(uint8_t (*func)(struct pt_regs *))
+int dtrace_invop_add(uint8_t (*func)(struct pt_regs *))
{
dtrace_invop_hdlr_t *hdlr;
hdlr = kmalloc(sizeof(dtrace_invop_hdlr_t), GFP_KERNEL);
+ if (hdlr == NULL) {
+ pr_warn("Failed to add invop handler: out of memory\n");
+ return -ENOMEM;
+ }
+
hdlr->dtih_func = func;
hdlr->dtih_next = dtrace_invop_hdlrs;
dtrace_invop_hdlrs = hdlr;
+
+ return 0;
}
EXPORT_SYMBOL(dtrace_invop_add);
for (;;) {
if (hdlr == NULL)
- pr_err("attempt to remove non-existant invop handler");
+ return;
if (hdlr->dtih_func == func)
break;