fsl_qbman: usdpaa: clear ioctl_dma_map string buffers
authorFlorinel Iordache <florinel.iordache@nxp.com>
Mon, 26 Apr 2021 06:32:26 +0000 (09:32 +0300)
committerFlorinel Iordache <florinel.iordache@nxp.com>
Mon, 26 Apr 2021 12:47:50 +0000 (14:47 +0200)
Clear all string buffers memory locations in ioctl_dma_map before using strncpy to copy the string name

Signed-off-by: Florinel Iordache <florinel.iordache@nxp.com>
drivers/staging/fsl_qbman/fsl_usdpaa.c

index 30d6704..b4e37f3 100644 (file)
@@ -1157,7 +1157,8 @@ do_map:
        if (i->did_create) {
                size_t name_len = 0;
                start_frag->flags = i->flags;
-               strncpy(start_frag->name, i->name, USDPAA_DMA_NAME_MAX);
+               memset(start_frag->name, '\0', USDPAA_DMA_NAME_MAX);
+               strncpy(start_frag->name, i->name, USDPAA_DMA_NAME_MAX - 1);
                name_len = strnlen(start_frag->name, USDPAA_DMA_NAME_MAX);
                if (name_len >= USDPAA_DMA_NAME_MAX) {
                        ret = -EFAULT;