Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 563ad2b6 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Ben Skeggs
Browse files

drm/nouveau/secboot: plug memory leak in ls_ucode_img_load_gr() error path



The last goto looks spurious because it releases less resources than the
previous one.
Also free 'img->sig' if 'ls_ucode_img_build()' fails.

Fixes: 9d896f3e ("drm/nouveau/secboot: abstract LS firmware loading functions")
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 9a2eba33
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ ls_ucode_img_load_gr(const struct nvkm_subdev *subdev, struct ls_ucode_img *img,
	ret = nvkm_firmware_get(subdev->device, f, &sig);
	if (ret)
		goto free_data;

	img->sig = kmemdup(sig->data, sig->size, GFP_KERNEL);
	if (!img->sig) {
		ret = -ENOMEM;
@@ -126,8 +127,9 @@ ls_ucode_img_load_gr(const struct nvkm_subdev *subdev, struct ls_ucode_img *img,
	img->ucode_data = ls_ucode_img_build(bl, code, data,
					     &img->ucode_desc);
	if (IS_ERR(img->ucode_data)) {
		kfree(img->sig);
		ret = PTR_ERR(img->ucode_data);
		goto free_data;
		goto free_sig;
	}
	img->ucode_size = img->ucode_desc.image_size;