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: <02507a9b-87e2-45a6-9410-d4dfb0e4b1a2@web.de>
Date: Tue, 17 Sep 2024 19:36:43 +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 1/2] drm/mediatek: Avoid duplicate sg_free_table(sgt) call in
 mtk_gem_prime_vmap()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Tue, 17 Sep 2024 18:50:37 +0200

A sg_free_table(sgt) call was immediately used after a null pointer check
for the data structure member “kvaddr” in this function implementation.
Thus use such a function call only once instead directly before the check.

This issue was transformed by using the Coccinelle software.

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

diff --git a/drivers/gpu/drm/mediatek/mtk_gem.c b/drivers/gpu/drm/mediatek/mtk_gem.c
index a172456d1d7b..9c7b7d0a3ffc 100644
--- a/drivers/gpu/drm/mediatek/mtk_gem.c
+++ b/drivers/gpu/drm/mediatek/mtk_gem.c
@@ -259,13 +259,13 @@ int mtk_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map)

 	mtk_gem->kvaddr = vmap(mtk_gem->pages, npages, VM_MAP,
 			       pgprot_writecombine(PAGE_KERNEL));
+	sg_free_table(sgt);
 	if (!mtk_gem->kvaddr) {
-		sg_free_table(sgt);
 		kfree(sgt);
 		kfree(mtk_gem->pages);
 		return -ENOMEM;
 	}
-	sg_free_table(sgt);
+
 	kfree(sgt);

 out:
--
2.46.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ