nouveau.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [Nouveau] [PATCH] drm/nouveau/acr: potential dereference of null pointer
@ 2021-12-16  2:18 Jiasheng Jiang
  0 siblings, 0 replies; only message in thread
From: Jiasheng Jiang @ 2021-12-16  2:18 UTC (permalink / raw)
  To: bskeggs, airlied, daniel; +Cc: nouveau, Jiasheng Jiang, linux-kernel, dri-devel

The return value of kmalloc() needs to be checked.
To avoid use in memcpy() in case of the failure of alloc.

Fixes: 22dcda45a3d1 ("drm/nouveau/acr: implement new subdev to replace "secure boot"")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/gpu/drm/nouveau/nvkm/subdev/acr/hsfw.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/acr/hsfw.c b/drivers/gpu/drm/nouveau/nvkm/subdev/acr/hsfw.c
index 667fa016496e..776573e77988 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/acr/hsfw.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/acr/hsfw.c
@@ -143,6 +143,9 @@ nvkm_acr_hsfw_load_bl(struct nvkm_acr *acr, const char *name, int ver,
 	hsfw->imem_size = desc->code_size;
 	hsfw->imem_tag = desc->start_tag;
 	hsfw->imem = kmalloc(desc->code_size, GFP_KERNEL);
+	if (!hsfw->imem)
+		return -ENOMEM;
+
 	memcpy(hsfw->imem, data + desc->code_off, desc->code_size);
 
 	nvkm_firmware_put(fw);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-16  8:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-16  2:18 [Nouveau] [PATCH] drm/nouveau/acr: potential dereference of null pointer Jiasheng Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).