From nobody Mon Feb 9 09:00:49 2026 Received: from mail-m49197.qiye.163.com (mail-m49197.qiye.163.com [45.254.49.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DC2525DD1E for ; Mon, 26 Jan 2026 12:32:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769430781; cv=none; b=oATZd7E3UtoRktxKRefIHKZaZHMwkboKK56/tQJ0gDVlxrJ/oB/l2ZD8xmjZA+GgZ3N/2JXHkDUOW6nGpEGoWaY9lyOUw9GiXdyNMTHt0Q+Le8Rj2ZVPVkOhtIMu+SHR9qiO2YgOXOmFwOA3gbsXwihoqJaDbCYth4qOdWtzjdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769430781; c=relaxed/simple; bh=UXD7AIP1SA4ExQJld40GFcy5SG/fRtZGyEcTcvwtOTA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=JpIpbLftb/jHti/ZcqKhLJNAJ5PNmhzwR395UTUzsV/VwDNjw+WGxekll7oYOaATuo5ijnsUPyPs5iXrfgh+ULvrQAS0WZZRx+injwor8sSJ0qgmHa9LazPi5Xcl7E/pbjzt4QXdA+5vBX5mOktUgVHSwrDHyP0e3wRxiSeoeZc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn; spf=pass smtp.mailfrom=seu.edu.cn; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b=eIYxit/y; arc=none smtp.client-ip=45.254.49.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b="eIYxit/y" Received: from LAPTOP-N070L597.localdomain (unknown [223.112.146.162]) by smtp.qiye.163.com (Hmail) with ESMTP id 3200b3fcf; Mon, 26 Jan 2026 20:32:51 +0800 (GMT+08:00) From: Zilin Guan To: lyude@redhat.com Cc: dakr@kernel.org, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, dri-devel@lists.freedesktop.org, bskeggs@redhat.com, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn, Zilin Guan Subject: [PATCH] drm/nouveau: Fix memory leak in nouveau_channel_ctor() Date: Mon, 26 Jan 2026 12:32:48 +0000 Message-Id: <20260126123248.164621-1-zilin@seu.edu.cn> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a9bfa4ae47903a1kunm8f0cf292523f X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVkaT08ZVk4ZQ0NNHUtLSBhJGFYeHw5VEwETFhoSFy QUDg9ZV1kYEgtZQVlJSUhVSkpJVUpPTVVKTUlZV1kWGg8SFR0UWUFZT0tIVUpLSUhOQ0NVSktLVU tZBg++ DKIM-Signature: a=rsa-sha256; b=eIYxit/y6p7SWGy1pZggvAgPpjfT1yrX9pCvMl5xLYgipmJ7vVBgm9r5z5PikCiPWeLH0CXgahoKqAWeVepNqmPD2ySRBP1WJDBTK94v4U8omj5s4R19PfHr8Jst+EKMUGJM8L8MhSm0bjGkrrLBUZZhFh+q5WrNIDTVCZz3cXg=; s=default; c=relaxed/relaxed; d=seu.edu.cn; v=1; bh=8uzYSpMQ1AKqTcHbWZbcyjdl+RkqVx3ltMWWymBf5O0=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" 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 --- 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/nouve= au/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 pri= v, u64 runm, ret =3D 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; + } =20 args->huserd =3D nvif_handle(&chan->mem_userd.object); args->ouserd =3D 0; --=20 2.34.1