diff mbox series

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

Message ID 20220728-rpi-analog-tv-properties-v2-17-f733a0ed9f90@cerno.tech (mailing list archive)
State New, archived
Headers show
Series drm: Analog TV Improvements | expand

Commit Message

Maxime Ripard Sept. 22, 2022, 2:25 p.m. UTC
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@cerno.tech>
diff mbox series

Patch

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.