]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
dmaengine: idxd: Replace memset(0) + strscpy() with strscpy_pad()
authorThorsten Blum <thorsten.blum@linux.dev>
Sun, 10 Aug 2025 22:58:59 +0000 (00:58 +0200)
committerVinod Koul <vkoul@kernel.org>
Wed, 20 Aug 2025 17:31:27 +0000 (23:01 +0530)
Replace memset(0) followed by strscpy() with strscpy_pad() to improve
idxd_load_iaa_device_defaults(). This avoids zeroing the memory before
copying the strings and ensures the destination buffers are only written
to once, simplifying the code and improving efficiency.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20250810225858.2953-2-thorsten.blum@linux.dev
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/idxd/defaults.c

index c607ae8dd12c614f2b358e033b127dbb9758de81..2bbbcd02a0dacf48f93f498f268a644abf972b41 100644 (file)
@@ -36,12 +36,10 @@ int idxd_load_iaa_device_defaults(struct idxd_device *idxd)
        group->num_wqs++;
 
        /* set name to "iaa_crypto" */
-       memset(wq->name, 0, WQ_NAME_SIZE + 1);
-       strscpy(wq->name, "iaa_crypto", WQ_NAME_SIZE + 1);
+       strscpy_pad(wq->name, "iaa_crypto");
 
        /* set driver_name to "crypto" */
-       memset(wq->driver_name, 0, DRIVER_NAME_SIZE + 1);
-       strscpy(wq->driver_name, "crypto", DRIVER_NAME_SIZE + 1);
+       strscpy_pad(wq->driver_name, "crypto");
 
        engine = idxd->engines[0];