drm/xe: Use kstrdup while creating snapshot
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Fri, 12 Jan 2024 16:06:52 +0000 (17:06 +0100)
committerLucas De Marchi <lucas.demarchi@intel.com>
Tue, 16 Jan 2024 16:09:43 +0000 (08:09 -0800)
There is no need to copy string step by step, use existing helper.

Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://lore.kernel.org/r/20240112160652.893-1-michal.wajdeczko@intel.com
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
drivers/gpu/drm/xe/xe_hw_engine.c

index e279ef6c527cd7fbc30015d54231091936b0fbc3..3aaab507f37febdffa267234cfd72e5eea053f80 100644 (file)
@@ -749,7 +749,6 @@ struct xe_hw_engine_snapshot *
 xe_hw_engine_snapshot_capture(struct xe_hw_engine *hwe)
 {
        struct xe_hw_engine_snapshot *snapshot;
-       int len;
 
        if (!xe_hw_engine_is_valid(hwe))
                return NULL;
@@ -759,11 +758,7 @@ xe_hw_engine_snapshot_capture(struct xe_hw_engine *hwe)
        if (!snapshot)
                return NULL;
 
-       len = strlen(hwe->name) + 1;
-       snapshot->name = kzalloc(len, GFP_ATOMIC);
-       if (snapshot->name)
-               strscpy(snapshot->name, hwe->name, len);
-
+       snapshot->name = kstrdup(hwe->name, GFP_ATOMIC);
        snapshot->class = hwe->class;
        snapshot->logical_instance = hwe->logical_instance;
        snapshot->forcewake.domain = hwe->domain;