]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
drm/nouveau/acr: Fix undefined behavior in nvkm_acr_hsfw_load_bl()
authorZhou Qingyang <zhou1615@umn.edu>
Mon, 24 Jan 2022 16:58:55 +0000 (00:58 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 11:57:58 +0000 (13:57 +0200)
commitff4b32f60c5cf11e9cbd0427b29c8461788b3da8
treec22fd701eee9111b81c5f69e47702a4c8cb64671
parent851bad5837cb25daef32de210ff6a9d596c26d3c
drm/nouveau/acr: Fix undefined behavior in nvkm_acr_hsfw_load_bl()

[ Upstream commit 2343bcdb4747d4f418a4daf2e898b94f86c24a59 ]

In nvkm_acr_hsfw_load_bl(), the return value of kmalloc() is directly
passed to memcpy(), which could lead to undefined behavior on failure
of kmalloc().

Fix this bug by using kmemdup() instead of kmalloc()+memcpy().

This bug was found by a static analyzer.

Builds with 'make allyesconfig' show no new warnings,
and our static analyzer no longer warns about this code.

Fixes: 22dcda45a3d1 ("drm/nouveau/acr: implement new subdev to replace "secure boot"")
Signed-off-by: Zhou Qingyang <zhou1615@umn.edu>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Lyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220124165856.57022-1-zhou1615@umn.edu
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/nouveau/nvkm/subdev/acr/hsfw.c