From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 01CA3502D5A; Wed, 30 Sep 2026 18:19:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790792374; cv=none; b=UrKpYNzQZY+3j7bERmz4LtngT98lSxUY8HQr2UXNnR/sIsmj0Z4xVnv3iFDB76ZoyCUwCCH3JDjkW24GBszWSDfjGslePUnfl+wh/UT3irTcxfmtgxG9QK2/0HjHoZGN3OSH3pXRHVB/IfEXEbP2kMp9PFAlA5zp+JGFzsFc3JQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790792374; c=relaxed/simple; bh=0YS/gPyKBYhoBU6o4afkTOwC0QfJFiY352uqPuiVWLY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YHmZiS+/LESoruTxaxiwoa5XK/KH6Fooeo08F1jxQGjUdA4P0sMM35QaTuH5jyyCCaEb12Ec38g2VPSijWrMFIlmotvV/KPFsISpkiObXvQP7Ug6d1uXYi71znqL/iPTa5Tsh49Lxg4H2ETwO8WCPtUEulQGUvKCdD+RU1ZyLUI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gNbae0pM; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="gNbae0pM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DD251F000FF; Wed, 30 Sep 2026 18:19:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790792372; bh=MXGwWWyqObWhba1r0e2reJgPzvExo+2oQv8tJPMGq2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gNbae0pM+NtGgHJk1B7IhHbSwj+S8FWg0uWscQ69ziiBXZsxWRIaqu3skZF4nL8Oh lZ8Tdyd6434Ixsti/tyLy9OZNe+Wgw5OGPyiDP1X6jnQPalgtH10EKaknAFAVKkJr5 SxAs+STt6FKNgQ1VO3vYaq2YhrRmMAf3flenBT4c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Junrui Luo , Dmitry Osipenko , Sasha Levin Subject: [PATCH 5.15 632/752] drm/virtio: release the GEM object on virtio_gpu_vram_create() errors Date: Wed, 30 Sep 2026 17:28:22 +0200 Message-ID: <20260930152411.946925008@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152358.131179731@linuxfoundation.org> References: <20260930152358.131179731@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Junrui Luo [ Upstream commit 036d28db1818af2f9d80db771f5405da84d7732d ] virtio_gpu_vram_create() frees the object with a bare kfree(vram) on both error paths after drm_gem_private_object_init() has run, and on the second one after drm_gem_create_mmap_offset() has linked obj->vma_node into the device's VMA offset manager. The freed object stays in that interval tree, so a later lookup or insertion walks freed memory, and the dma_resv and gpuva lock are never destroyed. Call drm_gem_object_release() before kfree() on both paths. Fixes: 16845c5d5409 ("drm/virtio: implement blob resources: implement vram object") Assisted-by: Claude:claude-opus-5 Signed-off-by: Junrui Luo Signed-off-by: Dmitry Osipenko Link: https://patch.msgid.link/20260915-fixes-v2-4-a0d799e4db66@outlook.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/virtio/virtgpu_vram.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_vram.c b/drivers/gpu/drm/virtio/virtgpu_vram.c index 5cc34e7330fa5..78162dca06fb4 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vram.c +++ b/drivers/gpu/drm/virtio/virtgpu_vram.c @@ -141,16 +141,12 @@ int virtio_gpu_vram_create(struct virtio_gpu_device *vgdev, /* Create fake offset */ ret = drm_gem_create_mmap_offset(obj); - if (ret) { - kfree(vram); - return ret; - } + if (ret) + goto err_release_obj; ret = virtio_gpu_resource_id_get(vgdev, &vram->base.hw_res_handle); - if (ret) { - kfree(vram); - return ret; - } + if (ret) + goto err_release_obj; virtio_gpu_cmd_resource_create_blob(vgdev, &vram->base, params, NULL, 0); @@ -164,4 +160,9 @@ int virtio_gpu_vram_create(struct virtio_gpu_device *vgdev, *bo_ptr = &vram->base; return 0; + +err_release_obj: + drm_gem_object_release(obj); + kfree(vram); + return ret; } -- 2.53.0