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-next>] [day] [month] [year] [list]
Message-ID: <202312081044568085747@zte.com.cn>
Date:   Fri, 8 Dec 2023 10:44:56 +0800 (CST)
From:   <yang.guang5@....com.cn>
To:     <harry.wentland@....com>
Cc:     <jiang.xuexin@....com.cn>, <chen.haonan2@....com.cn>,
        <cgel.zte@...il.com>, <sunpeng.li@....com>,
        <rodrigo.siqueira@....com>, <alexander.deucher@....com>,
        <christian.koenig@....com>, <xinhui.pan@....com>,
        <airlied@...il.com>, <daniel@...ll.ch>, <wenjing.liu@....com>,
        <jun.lei@....com>, <qingqing.zhuo@....com>, <alvin.lee2@....com>,
        <samson.tam@....com>, <aric.cyr@....com>, <chiawen.huang@....com>,
        <gabe.teeger@....com>, <amd-gfx@...ts.freedesktop.org>,
        <dri-devel@...ts.freedesktop.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH linux-next] drm/amd/display: replace kzalloc and memcpy with kmemdup

From: Yang Guang <yang.guang5@....com.cn>

Convert kzalloc/memcpy operations to memdup makes for 
cleaner code and avoids memcpy() failures

Signed-off-by: Chen Haonan <chen.haonan2@....com.cn>
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 76b47f178127..867e1a0fdef6 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -2264,12 +2264,10 @@ struct dc_state *dc_copy_state(struct dc_state *src_ctx)

 #ifdef CONFIG_DRM_AMD_DC_FP
 	if (new_ctx->bw_ctx.dml2) {
-		dml2 = kzalloc(sizeof(struct dml2_context), GFP_KERNEL);
-		if (!dml2)
-			return NULL;
-
-		memcpy(dml2, src_ctx->bw_ctx.dml2, sizeof(struct dml2_context));
-		new_ctx->bw_ctx.dml2 = dml2;
+		dml2 = kmemdup(src_ctx->bw_ctx.dml2, sizeof(struct dml2_context), GFP_KERNEL);
+		if (!dml2)
+			return NULL;
+		new_ctx->bw_ctx.dml2 = dml2;
 	}
 #endif

-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ