drm/modes: parse_cmdline: Fix possible reference past end of string
authorHans de Goede <hdegoede@redhat.com>
Mon, 18 Nov 2019 15:51:22 +0000 (16:51 +0100)
committerHans de Goede <hdegoede@redhat.com>
Mon, 16 Dec 2019 11:13:17 +0000 (12:13 +0100)
commit8582e244e5fe72d2e9ace186fa8f3ed3bb4122e1
treed4320f21786b04080144a502d8c7826f5062cc25
parent49a37dc393d774b7f7b8ba3944b75c7f8673b43a
drm/modes: parse_cmdline: Fix possible reference past end of string

Before this commit, if the last option of a video=... option is for
example "rotate" without a "=<value>" after it then delim will point to
the terminating 0 of the string, and value which is sets to <delim + 1>
will point one position past the end of the string.

This commit fixes this by enforcing that the contents of delim equals '='
as it should be for options which take a value, this check is done in a
new drm_mode_parse_cmdline_int helper function which factors out the
common integer parsing code for all the options which take an int.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-1-hdegoede@redhat.com
drivers/gpu/drm/drm_modes.c