summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drm-lease-manager/lease-manager.c3
-rw-r--r--drm-lease-manager/lease-server.c13
-rw-r--r--libdlmclient/dlmclient.c7
3 files changed, 14 insertions, 9 deletions
diff --git a/drm-lease-manager/lease-manager.c b/drm-lease-manager/lease-manager.c
index cfb1ab5..5eeef16 100644
--- a/drm-lease-manager/lease-manager.c
+++ b/drm-lease-manager/lease-manager.c
@@ -509,6 +509,7 @@ void lm_lease_close(struct lease_handle *handle)
assert(handle);
struct lease *lease = (struct lease *)handle;
- close(lease->lease_fd);
+ if (lease->lease_fd >= 0)
+ close(lease->lease_fd);
lease->lease_fd = -1;
}
diff --git a/drm-lease-manager/lease-server.c b/drm-lease-manager/lease-server.c
index a7e3190..8820305 100644
--- a/drm-lease-manager/lease-server.c
+++ b/drm-lease-manager/lease-server.c
@@ -266,15 +266,16 @@ struct ls *ls_create(struct lease_handle **lease_handles, int count)
return NULL;
}
- ls->servers = calloc(count, sizeof(struct ls_server));
- if (!ls->servers) {
- DEBUG_LOG("Memory allocation failed: %s\n", strerror(errno));
- goto err;
- }
-
ls->epoll_fd = epoll_create1(0);
if (ls->epoll_fd < 0) {
DEBUG_LOG("epoll_create failed: %s\n", strerror(errno));
+ free(ls);
+ return NULL;
+ }
+
+ ls->servers = calloc(count, sizeof(struct ls_server));
+ if (!ls->servers) {
+ DEBUG_LOG("Memory allocation failed: %s\n", strerror(errno));
goto err;
}
diff --git a/libdlmclient/dlmclient.c b/libdlmclient/dlmclient.c
index dbe2609..af7d3ac 100644
--- a/libdlmclient/dlmclient.c
+++ b/libdlmclient/dlmclient.c
@@ -120,7 +120,7 @@ struct dlm_lease *dlm_get_lease(const char *name)
}
if (!lease_send_request(lease, DLM_GET_LEASE))
- goto err;
+ goto err_request;
if (!lease_recv_fd(lease))
goto err;
@@ -129,8 +129,11 @@ struct dlm_lease *dlm_get_lease(const char *name)
err:
saved_errno = errno;
- dlm_release_lease(lease);
+ lease_send_request(lease, DLM_RELEASE_LEASE);
errno = saved_errno;
+err_request:
+ close(lease->dlm_server_sock);
+ free(lease);
return NULL;
}