]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
platform/x86: wmi: Break possible infinite loop when parsing GUID
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 21 Jun 2023 15:11:54 +0000 (18:11 +0300)
committerHans de Goede <hdegoede@redhat.com>
Mon, 10 Jul 2023 12:48:36 +0000 (14:48 +0200)
commit028e6e204ace1f080cfeacd72c50397eb8ae8883
tree16ea0f8922bff0501e5fac2603c25e93638dec85
parent06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5
platform/x86: wmi: Break possible infinite loop when parsing GUID

The while-loop may break on one of the two conditions, either ID string
is empty or GUID matches. The second one, may never be reached if the
parsed string is not correct GUID. In such a case the loop will never
advance to check the next ID.

Break possible infinite loop by factoring out guid_parse_and_compare()
helper which may be moved to the generic header for everyone later on
and preventing from similar mistake in the future.

Interestingly that firstly it appeared when WMI was turned into a bus
driver, but later when duplicated GUIDs were checked, the while-loop
has been replaced by for-loop and hence no mistake made again.

Fixes: a48e23385fcf ("platform/x86: wmi: add context pointer field to struct wmi_device_id")
Fixes: 844af950da94 ("platform/x86: wmi: Turn WMI into a bus driver")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230621151155.78279-1-andriy.shevchenko@linux.intel.com
Tested-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/wmi.c