plymouth/plymouth-renderers-Do-not-assume-all-keyboards-have-LEDs.patch
Cliff Zhao f66b57318b Accepting request 1226800 from home:tdz:branches:Base:System
- Add plymouth-renderers-Do-not-assume-all-keyboards-have-LEDs.patch:
  Plymouth does not recognize keyboards without LEDs. This leads to
  a NULL-pointer deref in the input code. Fixed by this patch. The
  change is commit 709f21e8 ("renderers: Do not assume all keyboards
  have LEDs") in the upstrema tree. (bsc#1233532)

OBS-URL: https://build.opensuse.org/request/show/1226800
OBS-URL: https://build.opensuse.org/package/show/Base:System/plymouth?expand=0&rev=385
2024-11-27 08:01:14 +00:00

106 lines
4.0 KiB
Diff

From 709f21e80199ee51badff2d9b5dc6bae8af2a1a1 Mon Sep 17 00:00:00 2001
From: n3rdopolis <bluescreen_avenger@verizon.net>
Date: Wed, 31 Jan 2024 08:38:38 -0500
Subject: [PATCH] renderers: Do not assume all keyboards have LEDs
This is an attempt to fix #245
---
src/plugins/renderers/drm/plugin.c | 22 +++++++++++++++++++--
src/plugins/renderers/frame-buffer/plugin.c | 22 +++++++++++++++++++--
2 files changed, 40 insertions(+), 4 deletions(-)
Index: plymouth-22.02.122+180.b1d5aa9/src/plugins/renderers/drm/plugin.c
===================================================================
--- plymouth-22.02.122+180.b1d5aa9.orig/src/plugins/renderers/drm/plugin.c
+++ plymouth-22.02.122+180.b1d5aa9/src/plugins/renderers/drm/plugin.c
@@ -1926,6 +1926,17 @@ get_panel_properties (ply_renderer_backe
}
static ply_input_device_t *
+get_any_input_device (ply_renderer_backend_t *backend)
+{
+ ply_list_node_t *node = ply_list_get_first_node (backend->input_source.input_devices);
+
+ if (node != NULL)
+ return ply_list_node_get_data (node);
+
+ return NULL;
+}
+
+static ply_input_device_t *
get_any_input_device_with_leds (ply_renderer_backend_t *backend)
{
ply_list_node_t *node;
@@ -1947,6 +1958,9 @@ get_capslock_state (ply_renderer_backend
{
if (using_input_device (&backend->input_source)) {
ply_input_device_t *dev = get_any_input_device_with_leds (backend);
+ if (!dev)
+ return false;
+
return ply_input_device_get_capslock_state (dev);
}
if (!backend->terminal)
@@ -1959,8 +1973,12 @@ static const char *
get_keymap (ply_renderer_backend_t *backend)
{
if (using_input_device (&backend->input_source)) {
- ply_input_device_t *dev = get_any_input_device_with_leds (backend);
- const char *keymap = ply_input_device_get_keymap (dev);
+ const char *keymap;
+ ply_input_device_t *dev = get_any_input_device (backend);
+ if (!dev)
+ return NULL;
+
+ keymap = ply_input_device_get_keymap (dev);
if (keymap != NULL) {
return keymap;
}
Index: plymouth-22.02.122+180.b1d5aa9/src/plugins/renderers/frame-buffer/plugin.c
===================================================================
--- plymouth-22.02.122+180.b1d5aa9.orig/src/plugins/renderers/frame-buffer/plugin.c
+++ plymouth-22.02.122+180.b1d5aa9/src/plugins/renderers/frame-buffer/plugin.c
@@ -816,6 +816,17 @@ close_input_source (ply_renderer_backend
}
static ply_input_device_t *
+get_any_input_device (ply_renderer_backend_t *backend)
+{
+ ply_list_node_t *node = ply_list_get_first_node (backend->input_source.input_devices);
+
+ if (node != NULL)
+ return ply_list_node_get_data (node);
+
+ return NULL;
+}
+
+static ply_input_device_t *
get_any_input_device_with_leds (ply_renderer_backend_t *backend)
{
ply_list_node_t *node;
@@ -837,6 +848,9 @@ get_capslock_state (ply_renderer_backend
{
if (using_input_device (&backend->input_source)) {
ply_input_device_t *dev = get_any_input_device_with_leds (backend);
+ if (!dev)
+ return false;
+
return ply_input_device_get_capslock_state (dev);
}
if (!backend->terminal)
@@ -849,8 +863,12 @@ static const char *
get_keymap (ply_renderer_backend_t *backend)
{
if (using_input_device (&backend->input_source)) {
- ply_input_device_t *dev = get_any_input_device_with_leds (backend);
- const char *keymap = ply_input_device_get_keymap (dev);
+ const char *keymap;
+ ply_input_device_t *dev = get_any_input_device (backend);
+ if (!dev)
+ return NULL;
+
+ keymap = ply_input_device_get_keymap (dev);
if (keymap != NULL) {
return keymap;
}