[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <79e3e2f047e8df3b7a1ac69a5c24016f799823d0@intel.com>
Date: Thu, 04 Dec 2025 13:49:00 +0200
From: Jani Nikula <jani.nikula@...ux.intel.com>
To: Madhur Kumar <madhurkumar004@...il.com>, lyude@...hat.com, dakr@...nel.org
Cc: maarten.lankhorst@...ux.intel.com, mripard@...nel.org,
tzimmermann@...e.de, airlied@...il.com, simona@...ll.ch,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
nouveau@...ts.freedesktop.org, Madhur Kumar <madhurkumar004@...il.com>
Subject: Re: [PATCH] drm/nouveau : refactor deprecated strcpy
On Thu, 04 Dec 2025, Madhur Kumar <madhurkumar004@...il.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@...il.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
Powered by blists - more mailing lists