thread: Fix error handling in spdk_interrupt_register
If the calloc failed, the fd was left in the fd_group. Change-Id: Ie68426a13d342756c20315656f0309440fda6e02 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15475 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <levon@movementarian.org>
This commit is contained in:
parent
8dbaca1300
commit
85478eccc9
@ -2634,14 +2634,6 @@ spdk_interrupt_register(int efd, spdk_interrupt_fn fn,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = spdk_fd_group_add(thread->fgrp, efd, fn, arg, name);
|
||||
|
||||
if (ret != 0) {
|
||||
SPDK_ERRLOG("thread %s: failed to add fd %d: %s\n",
|
||||
thread->name, efd, spdk_strerror(-ret));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
intr = calloc(1, sizeof(*intr));
|
||||
if (intr == NULL) {
|
||||
SPDK_ERRLOG("Interrupt handler allocation failed\n");
|
||||
@ -2657,6 +2649,15 @@ spdk_interrupt_register(int efd, spdk_interrupt_fn fn,
|
||||
intr->efd = efd;
|
||||
intr->thread = thread;
|
||||
|
||||
ret = spdk_fd_group_add(thread->fgrp, efd, fn, arg, name);
|
||||
|
||||
if (ret != 0) {
|
||||
SPDK_ERRLOG("thread %s: failed to add fd %d: %s\n",
|
||||
thread->name, efd, spdk_strerror(-ret));
|
||||
free(intr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return intr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user