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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aa103a36-8cb3-4232-b4b7-3ffd117e303b@web.de>
Date: Tue, 17 Sep 2024 19:42:30 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: linux-mediatek@...ts.infradead.org, linux-arm-kernel@...ts.infradead.org,
 dri-devel@...ts.freedesktop.org, Alexandre Mergnat <amergnat@...libre.com>,
 Angelo Gioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
 Chen-Yu Tsai <wenst@...omium.org>, Chun-Kuang Hu <chunkuang.hu@...nel.org>,
 David Airlie <airlied@...il.com>, Matthias Brugger <matthias.bgg@...il.com>,
 Philipp Zabel <p.zabel@...gutronix.de>, Simona Vetter <simona@...ll.ch>,
 Sui Jingfeng <suijingfeng@...ngson.cn>,
 Thomas Zimmermann <tzimmermann@...e.de>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 2/2] drm/mediatek: Use common error handling code in
 mtk_gem_prime_vmap()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Tue, 17 Sep 2024 19:06:23 +0200

Add a jump target so that a bit of exception handling can be better reused
at the end of this function implementation.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 drivers/gpu/drm/mediatek/mtk_gem.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_gem.c b/drivers/gpu/drm/mediatek/mtk_gem.c
index 9c7b7d0a3ffc..5713156efb4e 100644
--- a/drivers/gpu/drm/mediatek/mtk_gem.c
+++ b/drivers/gpu/drm/mediatek/mtk_gem.c
@@ -251,8 +251,7 @@ int mtk_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map)
 	mtk_gem->pages = kcalloc(npages, sizeof(*mtk_gem->pages), GFP_KERNEL);
 	if (!mtk_gem->pages) {
 		sg_free_table(sgt);
-		kfree(sgt);
-		return -ENOMEM;
+		goto free_sgt;
 	}

 	drm_prime_sg_to_page_array(sgt, mtk_gem->pages, npages);
@@ -261,9 +260,8 @@ int mtk_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map)
 			       pgprot_writecombine(PAGE_KERNEL));
 	sg_free_table(sgt);
 	if (!mtk_gem->kvaddr) {
-		kfree(sgt);
 		kfree(mtk_gem->pages);
-		return -ENOMEM;
+		goto free_sgt;
 	}

 	kfree(sgt);
@@ -272,6 +270,10 @@ int mtk_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map)
 	iosys_map_set_vaddr(map, mtk_gem->kvaddr);

 	return 0;
+
+free_sgt:
+	kfree(sgt);
+	return -ENOMEM;
 }

 void mtk_gem_prime_vunmap(struct drm_gem_object *obj, struct iosys_map *map)
--
2.46.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ