Message ID | 20250225203932.334123-1-thorsten.blum@linux.dev (mailing list archive) |
---|---|
State | In Next |
Commit | ce43cf347759936bd7b16d66b5b5072757756e4a |
Headers | show |
Series | drm/gma500: Replace deprecated strncpy() with strscpy() | expand |
On Tue, Feb 25, 2025 at 09:39:32PM +0100, Thorsten Blum wrote: > strncpy() is deprecated for NUL-terminated destination buffers. Use > strscpy() instead and remove the manual NUL-termination. > > Compile-tested only. > > Link: https://github.com/KSPP/linux/issues/90 > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Yup, the adapter var is already zeroed out, so even if NUL padding is needed, it is already present. Reviewed-by: Kees Cook <kees@kernel.org>
On Tue, Feb 25, 2025 at 9:39 PM Thorsten Blum <thorsten.blum@linux.dev> wrote: > > strncpy() is deprecated for NUL-terminated destination buffers. Use > strscpy() instead and remove the manual NUL-termination. > > Compile-tested only. > > Link: https://github.com/KSPP/linux/issues/90 > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Thanks for the patch. Applied to drm-misc-next -Patrik > --- > drivers/gpu/drm/gma500/cdv_intel_dp.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/gma500/cdv_intel_dp.c b/drivers/gpu/drm/gma500/cdv_intel_dp.c > index cc2ed9b3fd2d..ca7f59ff1fda 100644 > --- a/drivers/gpu/drm/gma500/cdv_intel_dp.c > +++ b/drivers/gpu/drm/gma500/cdv_intel_dp.c > @@ -855,8 +855,7 @@ cdv_intel_dp_i2c_init(struct gma_connector *connector, > > memset(&intel_dp->adapter, '\0', sizeof (intel_dp->adapter)); > intel_dp->adapter.owner = THIS_MODULE; > - strncpy (intel_dp->adapter.name, name, sizeof(intel_dp->adapter.name) - 1); > - intel_dp->adapter.name[sizeof(intel_dp->adapter.name) - 1] = '\0'; > + strscpy(intel_dp->adapter.name, name); > intel_dp->adapter.algo_data = &intel_dp->algo; > intel_dp->adapter.dev.parent = connector->base.kdev; > > -- > 2.48.1 >
diff --git a/drivers/gpu/drm/gma500/cdv_intel_dp.c b/drivers/gpu/drm/gma500/cdv_intel_dp.c index cc2ed9b3fd2d..ca7f59ff1fda 100644 --- a/drivers/gpu/drm/gma500/cdv_intel_dp.c +++ b/drivers/gpu/drm/gma500/cdv_intel_dp.c @@ -855,8 +855,7 @@ cdv_intel_dp_i2c_init(struct gma_connector *connector, memset(&intel_dp->adapter, '\0', sizeof (intel_dp->adapter)); intel_dp->adapter.owner = THIS_MODULE; - strncpy (intel_dp->adapter.name, name, sizeof(intel_dp->adapter.name) - 1); - intel_dp->adapter.name[sizeof(intel_dp->adapter.name) - 1] = '\0'; + strscpy(intel_dp->adapter.name, name); intel_dp->adapter.algo_data = &intel_dp->algo; intel_dp->adapter.dev.parent = connector->base.kdev;
strncpy() is deprecated for NUL-terminated destination buffers. Use strscpy() instead and remove the manual NUL-termination. Compile-tested only. Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> --- drivers/gpu/drm/gma500/cdv_intel_dp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)