mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-10 15:54:39 +08:00
drm/i915: refactor deprecated strncpy
`strncpy` is deprecated for use on NUL-terminated destination strings [1]. We should prefer more robust and less ambiguous string interfaces. A suitable replacement is `strscpy` [2] due to the fact that it guarantees NUL-termination on the destination buffer without unnecessarily NUL-padding. `ctx` is zero allocated and as such strncpy's NUL-padding behavior was strictly a performance hit which is now resolved. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2] Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt <justinstitt@google.com> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
This commit is contained in:
parent
afddcbe41f
commit
5642639bd4
@ -36,7 +36,7 @@ mock_context(struct drm_i915_private *i915,
|
|||||||
if (name) {
|
if (name) {
|
||||||
struct i915_ppgtt *ppgtt;
|
struct i915_ppgtt *ppgtt;
|
||||||
|
|
||||||
strncpy(ctx->name, name, sizeof(ctx->name) - 1);
|
strscpy(ctx->name, name, sizeof(ctx->name));
|
||||||
|
|
||||||
ppgtt = mock_ppgtt(i915, name);
|
ppgtt = mock_ppgtt(i915, name);
|
||||||
if (!ppgtt)
|
if (!ppgtt)
|
||||||
|
Loading…
Reference in New Issue
Block a user