Message ID | 20211216021823.281472-1-jiasheng@iscas.ac.cn (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/nouveau/acr: potential dereference of null pointer | expand |
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);
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(+)