mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Madhur Kumar <madhurkumar004@gmail.com>,
	lyude@redhat.com, dakr@kernel.org
Cc: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	nouveau@lists.freedesktop.org,
	Madhur Kumar <madhurkumar004@gmail.com>
Subject: Re: [PATCH] drm/nouveau : refactor deprecated strcpy
Date: Thu, 04 Dec 2025 13:49:00 +0200	[thread overview]
Message-ID: <79e3e2f047e8df3b7a1ac69a5c24016f799823d0@intel.com> (raw)
In-Reply-To: <20251204114021.36719-1-madhurkumar004@gmail.com>

On Thu, 04 Dec 2025, Madhur Kumar <madhurkumar004@gmail.com> wrote:
> strcpy() has been deprecated because it performs no bounds checking on the
> destination buffer, which can lead to buffer overflows. Use the safer
> strscpy() instead.
>
> Signed-off-by: Madhur Kumar <madhurkumar004@gmail.com>
> ---
>  drivers/gpu/drm/nouveau/nouveau_fence.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.c b/drivers/gpu/drm/nouveau/nouveau_fence.c
> index 869d4335c0f4..100c7dff4ff8 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_fence.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_fence.c
> @@ -183,11 +183,11 @@ nouveau_fence_context_new(struct nouveau_channel *chan, struct nouveau_fence_cha
>  	fctx->context = drm->runl[chan->runlist].context_base + chan->chid;
>  
>  	if (chan == drm->cechan)
> -		strcpy(fctx->name, "copy engine channel");
> +		strscpy(fctx->name, "copy engine channel", sizeof(fctx->name));
>  	else if (chan == drm->channel)
> -		strcpy(fctx->name, "generic kernel channel");
> +		strscpy(fctx->name, "generic kernel channel", sizeof(fctx->name));
>  	else
> -		strcpy(fctx->name, cli->name);
> +		strscpy(fctx->name, cli->name, sizeof(fctx->name));

I don't think you actually need the third parameter here. strscpy() is
magic, look up its definition.

BR,
Jani.

>  
>  	kref_init(&fctx->fence_ref);
>  	if (!priv->uevent)

-- 
Jani Nikula, Intel

  reply	other threads:[~2025-12-04 11:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-04 11:40 Madhur Kumar
2025-12-04 11:49 ` Jani Nikula [this message]
2025-12-04 12:08 ` [PATCH v2] " Madhur Kumar
2025-12-05 19:55   ` Lyude Paul

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=79e3e2f047e8df3b7a1ac69a5c24016f799823d0@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=airlied@gmail.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lyude@redhat.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=madhurkumar004@gmail.com \
    --cc=mripard@kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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®