]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
drm/amdgpu: Fix NULL dereference in dpm sysfs handlers
authorPaweł Gronowski <me@woland.xyz>
Sun, 19 Jul 2020 15:54:53 +0000 (17:54 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jul 2020 08:19:59 +0000 (10:19 +0200)
commitf69137b000ffcfc726e8f3d567e0b69b34a49649
tree2a6c24b792774dc25100336efaea3a58ee30aa94
parent04e469ed6c5ed4f2f8d0aa7e1fcb91360a33c907
drm/amdgpu: Fix NULL dereference in dpm sysfs handlers

commit 38e0c89a19fd13f28d2b4721035160a3e66e270b upstream.

NULL dereference occurs when string that is not ended with space or
newline is written to some dpm sysfs interface (for example pp_dpm_sclk).
This happens because strsep replaces the tmp with NULL if the delimiter
is not present in string, which is then dereferenced by tmp[0].

Reproduction example:
sudo sh -c 'echo -n 1 > /sys/class/drm/card0/device/pp_dpm_sclk'

Signed-off-by: Paweł Gronowski <me@woland.xyz>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c