mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <yang.guang5@zte.com.cn>
To: <harry.wentland@amd.com>
Cc: <jiang.xuexin@zte.com.cn>, <chen.haonan2@zte.com.cn>,
	<cgel.zte@gmail.com>, <sunpeng.li@amd.com>,
	<rodrigo.siqueira@amd.com>, <alexander.deucher@amd.com>,
	<christian.koenig@amd.com>, <xinhui.pan@amd.com>,
	<airlied@gmail.com>, <daniel@ffwll.ch>, <wenjing.liu@amd.com>,
	<jun.lei@amd.com>, <qingqing.zhuo@amd.com>, <alvin.lee2@amd.com>,
	<samson.tam@amd.com>, <aric.cyr@amd.com>, <chiawen.huang@amd.com>,
	<gabe.teeger@amd.com>, <amd-gfx@lists.freedesktop.org>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH linux-next] drm/amd/display: replace kzalloc and memcpy with kmemdup
Date: Fri, 8 Dec 2023 10:44:56 +0800 (CST)	[thread overview]
Message-ID: <202312081044568085747@zte.com.cn> (raw)

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

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

Signed-off-by: Chen Haonan <chen.haonan2@zte.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

             reply	other threads:[~2023-12-08  2:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08  2:44 yang.guang5 [this message]
2023-12-08 17:45 ` Christophe JAILLET

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202312081044568085747@zte.com.cn \
    --to=yang.guang5@zte.com.cn \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=alvin.lee2@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=aric.cyr@amd.com \
    --cc=cgel.zte@gmail.com \
    --cc=chen.haonan2@zte.com.cn \
    --cc=chiawen.huang@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gabe.teeger@amd.com \
    --cc=harry.wentland@amd.com \
    --cc=jiang.xuexin@zte.com.cn \
    --cc=jun.lei@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qingqing.zhuo@amd.com \
    --cc=rodrigo.siqueira@amd.com \
    --cc=samson.tam@amd.com \
    --cc=sunpeng.li@amd.com \
    --cc=wenjing.liu@amd.com \
    --cc=xinhui.pan@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®