mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: yang.guang5@zte.com.cn, 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: Re: [PATCH linux-next] drm/amd/display: replace kzalloc and memcpy with kmemdup
Date: Fri, 8 Dec 2023 18:45:50 +0100	[thread overview]
Message-ID: <26dd45f4-8fb7-476f-b8ec-9cb685a138ef@wanadoo.fr> (raw)
In-Reply-To: <202312081044568085747@zte.com.cn>

Le 08/12/2023 à 03:44, yang.guang5@zte.com.cn a écrit :
> From: Yang Guang <yang.guang5@zte.com.cn>
> 
> Convert kzalloc/memcpy operations to memdup makes for
> cleaner code and avoids memcpy() failures

Hi,

usually, function's names are written with () in commit description. 
(i.e. kzalloc()/memcpy()).

memdup should be kmemdup().

Finally the proposed change does not avoid memcpy() failures. Should it 
fail (what does it mean in this context?), kmemdup() would behave 
exactly the same.

> 
> 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);

sizeof(struct dml2_context) could be sizeof(*dlm2) to be less verbose.

CJ

> +		if (!dml2)
> +			return NULL;
> +		new_ctx->bw_ctx.dml2 = dml2;
>   	}
>   #endif
> 


      reply	other threads:[~2023-12-08 17:46 UTC|newest]

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

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=26dd45f4-8fb7-476f-b8ec-9cb685a138ef@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --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 \
    --cc=yang.guang5@zte.com.cn \
    /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®