lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20260126123248.164621-1-zilin@seu.edu.cn>
Date: Mon, 26 Jan 2026 12:32:48 +0000
From: Zilin Guan <zilin@....edu.cn>
To: lyude@...hat.com
Cc: dakr@...nel.org,
	maarten.lankhorst@...ux.intel.com,
	mripard@...nel.org,
	tzimmermann@...e.de,
	airlied@...il.com,
	simona@...ll.ch,
	dri-devel@...ts.freedesktop.org,
	bskeggs@...hat.com,
	nouveau@...ts.freedesktop.org,
	linux-kernel@...r.kernel.org,
	jianhao.xu@....edu.cn,
	Zilin Guan <zilin@....edu.cn>
Subject: [PATCH] drm/nouveau: Fix memory leak in nouveau_channel_ctor()

In nouveau_channel_ctor(), nouveau_channel_prep() allocates the channel
structure. If nvif_mem_ctor() fails to allocate the userd memory, the
function returns without freeing the channel, resulting in a memory leak.

Add nouveau_channel_del() to the error path to ensure the allocated
channel is properly freed.

Compile tested only. Issue found using a prototype static analysis tool
and code review.

Fixes: 06db7fded6de ("drm/nouveau/fifo: add new channel classes")
Signed-off-by: Zilin Guan <zilin@....edu.cn>
---
 drivers/gpu/drm/nouveau/nouveau_chan.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index b1e92b1f7a26..a421c32fda02 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -322,8 +322,10 @@ nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
 		ret = nvif_mem_ctor(&cli->mmu, "abi16ChanUSERD", NVIF_CLASS_MEM_GF100,
 				    NVIF_MEM_VRAM | NVIF_MEM_COHERENT | NVIF_MEM_MAPPABLE,
 				    0, PAGE_SIZE, NULL, 0, &chan->mem_userd);
-		if (ret)
+		if (ret) {
+			nouveau_channel_del(pchan);
 			return ret;
+		}
 
 		args->huserd = nvif_handle(&chan->mem_userd.object);
 		args->ouserd = 0;
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ