aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/drm/drm.c17
-rw-r--r--backend/libinput/events.c5
-rw-r--r--backend/multi/backend.c8
-rw-r--r--backend/wayland/output.c12
-rw-r--r--backend/wayland/wl_seat.c8
5 files changed, 40 insertions, 10 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 424c7685..9b4cee2f 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -748,8 +748,13 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
parse_edid(&output->output, edid_len, edid);
free(edid);
+ if (list_add(backend->outputs, output) == -1) {
+ wlr_log_errno(L_ERROR, "Allocation failed");
+ drmModeFreeConnector(conn);
+ free(output);
+ continue;
+ }
wlr_output_create_global(&output->output, backend->display);
- list_add(backend->outputs, output);
wlr_log(L_INFO, "Found display '%s'", output->output.name);
} else {
output = backend->outputs->items[index];
@@ -764,6 +769,10 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
for (int i = 0; i < conn->count_modes; ++i) {
struct wlr_drm_output_mode *mode = calloc(1,
sizeof(struct wlr_drm_output_mode));
+ if (!mode) {
+ wlr_log_errno(L_ERROR, "Allocation failed");
+ continue;
+ }
mode->mode = conn->modes[i];
mode->wlr_mode.width = mode->mode.hdisplay;
mode->wlr_mode.height = mode->mode.vdisplay;
@@ -773,7 +782,11 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *backend) {
mode->wlr_mode.width, mode->wlr_mode.height,
mode->wlr_mode.refresh);
- list_add(output->output.modes, mode);
+ if (list_add(backend->outputs, output) == -1) {
+ wlr_log_errno(L_ERROR, "Allocation failed");
+ free(mode);
+ continue;
+ }
}
output->state = WLR_DRM_OUTPUT_NEEDS_MODESET;
diff --git a/backend/libinput/events.c b/backend/libinput/events.c
index dc5e4cb1..2a396536 100644
--- a/backend/libinput/events.c
+++ b/backend/libinput/events.c
@@ -44,11 +44,14 @@ static struct wlr_input_device *allocate_device(
return NULL;
}
struct wlr_input_device *wlr_dev = &wlr_libinput_dev->wlr_input_device;
+ if (list_add(wlr_devices, wlr_dev) == -1) {
+ free(wlr_libinput_dev);
+ return NULL;
+ }
wlr_libinput_dev->handle = libinput_dev;
libinput_device_ref(libinput_dev);
wlr_input_device_init(wlr_dev, type, &input_device_impl,
name, vendor, product);
- list_add(wlr_devices, wlr_dev);
return wlr_dev;
}
diff --git a/backend/multi/backend.c b/backend/multi/backend.c
index 290b9678..33b26a0a 100644
--- a/backend/multi/backend.c
+++ b/backend/multi/backend.c
@@ -120,6 +120,12 @@ void wlr_multi_backend_add(struct wlr_backend *_multi,
wlr_log(L_ERROR, "Could not add backend: allocation failed");
return;
}
+ if (list_add(multi->backends, sub) == -1) {
+ wlr_log(L_ERROR, "Could not add backend: allocation failed");
+ free(sub);
+ return;
+ }
+
sub->backend = backend;
sub->container = &multi->backend;
@@ -137,8 +143,6 @@ void wlr_multi_backend_add(struct wlr_backend *_multi,
wl_signal_add(&backend->events.input_remove, &sub->input_remove);
wl_signal_add(&backend->events.output_add, &sub->output_add);
wl_signal_add(&backend->events.output_remove, &sub->output_remove);
-
- list_add(multi->backends, sub);
}
struct wlr_session *wlr_multi_get_session(struct wlr_backend *_backend) {
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index cb286316..786dc46e 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -236,7 +236,8 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
output->egl_surface, output->egl_surface,
output->backend->egl.context)) {
wlr_log(L_ERROR, "eglMakeCurrent failed: %s", egl_error());
- return false;
+ free(output);
+ return NULL;
}
glViewport(0, 0, wlr_output->width, wlr_output->height);
@@ -248,11 +249,16 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
if (!eglSwapBuffers(output->backend->egl.display, output->egl_surface)) {
wlr_log(L_ERROR, "eglSwapBuffers failed: %s", egl_error());
- return false;
+ free(output);
+ return NULL;
}
+ if (list_add(backend->outputs, wlr_output) == -1) {
+ wlr_log(L_ERROR, "Allocation failed");
+ free(output);
+ return NULL;
+ }
wlr_output_create_global(wlr_output, backend->local_display);
- list_add(backend->outputs, wlr_output);
wl_signal_emit(&backend->backend.events.output_add, wlr_output);
return wlr_output;
}
diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c
index 4668a72b..a4cc0ba5 100644
--- a/backend/wayland/wl_seat.c
+++ b/backend/wayland/wl_seat.c
@@ -188,7 +188,7 @@ static struct wlr_input_device *allocate_device(struct wlr_wl_backend *backend,
enum wlr_input_device_type type) {
struct wlr_wl_input_device *wlr_wl_dev;
if (!(wlr_wl_dev = calloc(1, sizeof(struct wlr_wl_input_device)))) {
- wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno));
+ wlr_log_errno(L_ERROR, "Allocation failed");
return NULL;
}
@@ -200,7 +200,11 @@ static struct wlr_input_device *allocate_device(struct wlr_wl_backend *backend,
struct wlr_input_device *wlr_device = &wlr_wl_dev->wlr_input_device;
wlr_input_device_init(wlr_device, type, &input_device_impl,
name, vendor, product);
- list_add(backend->devices, wlr_device);
+ if (list_add(backend->devices, wlr_device) == -1) {
+ wlr_log_errno(L_ERROR, "Allocation failed");
+ free(wlr_wl_dev);
+ return NULL;
+ }
return wlr_device;
}