From 578b28a0ecb219cda2c005fb8d4ef244c2edc19d Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Wed, 29 Apr 2026 15:43:24 +0200 Subject: [PATCH] utils: Fail early when calling bd_utils_resolve_device with NULL gcc static analyzer is complaining about this and the produced error in case is quite cryptic. --- src/utils/dev_utils.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils/dev_utils.c b/src/utils/dev_utils.c index 89a54b4ca..9280b8078 100644 --- a/src/utils/dev_utils.c +++ b/src/utils/dev_utils.c @@ -64,6 +64,12 @@ gchar* bd_utils_resolve_device (const gchar *dev_spec, GError **error) { g_autofree gchar *symlink = NULL; GError *l_error = NULL; + if (dev_spec == NULL) { + g_set_error (error, BD_UTILS_DEV_UTILS_ERROR, BD_UTILS_DEV_UTILS_ERROR_FAILED, + "Device specification required"); + return NULL; + } + if (!g_str_has_prefix (dev_spec, "/dev/")) path = g_strdup_printf ("/dev/%s", dev_spec); else