[Intel-gfx] [PATCH v2 17/33] drm/modes: Bail out of named mode parsing early if it's an option

Maxime Ripard maxime at cerno.tech
Thu Sep 22 14:25:34 UTC 2022


The name we are given is the first part of the command line split at a
comma.

We can thus be called in two cases, either we are parsing a (named?)
mode, before the optional part separated by a comma, or we never had a
mode specified but only options.

Options use the equal sign as separator between the name and its value,
so if we ever find an equal sign in our string, we can bail early since
we never had a mode to parse.

Signed-off-by: Maxime Ripard <maxime at cerno.tech>

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index ede5b094da4c..dc5d5bdbea7a 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -2242,6 +2242,13 @@ static int drm_mode_parse_cmdline_named_mode(const char *name,
 	if (isdigit(name[0]))
 		return 0;
 
+	/*
+	 * If there's an equal sign in the name, the command-line
+	 * contains only an option and no mode.
+	 */
+	if (strnchr(name, name_end, '='))
+		return 0;
+
 	/*
 	 * We're sure we're a named mode at that point, iterate over the
 	 * list of modes we're aware of.

-- 
b4 0.10.0


More information about the Intel-gfx mailing list