2022-07-11 14:38:33

by XueBing Chen

[permalink] [raw]
Subject: [PATCH] dmaengine: xilinx: use strscpy to replace strlcpy


The strlcpy should not be used because it doesn't limit the source
length. Preferred is strscpy.

Signed-off-by: XueBing Chen <[email protected]>
---
drivers/dma/xilinx/xilinx_dpdma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/xilinx/xilinx_dpdma.c b/drivers/dma/xilinx/xilinx_dpdma.c
index b0f4948b00a5..f5815465e83b 100644
--- a/drivers/dma/xilinx/xilinx_dpdma.c
+++ b/drivers/dma/xilinx/xilinx_dpdma.c
@@ -376,7 +376,7 @@ static ssize_t xilinx_dpdma_debugfs_read(struct file *f, char __user *buf,
if (ret < 0)
goto done;
} else {
- strlcpy(kern_buff, "No testcase executed",
+ strscpy(kern_buff, "No testcase executed",
XILINX_DPDMA_DEBUGFS_READ_MAX_SIZE);
}

--
2.25.1


2022-07-11 17:42:57

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH] dmaengine: xilinx: use strscpy to replace strlcpy

Hi XueBing,

Thank you for the patch.

On Mon, Jul 11, 2022 at 10:05:33PM +0800, XueBing Chen wrote:
>
> The strlcpy should not be used because it doesn't limit the source
> length. Preferred is strscpy.
>
> Signed-off-by: XueBing Chen <[email protected]>

Reviewed-by: Laurent Pinchart <[email protected]>

> ---
> drivers/dma/xilinx/xilinx_dpdma.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma/xilinx/xilinx_dpdma.c b/drivers/dma/xilinx/xilinx_dpdma.c
> index b0f4948b00a5..f5815465e83b 100644
> --- a/drivers/dma/xilinx/xilinx_dpdma.c
> +++ b/drivers/dma/xilinx/xilinx_dpdma.c
> @@ -376,7 +376,7 @@ static ssize_t xilinx_dpdma_debugfs_read(struct file *f, char __user *buf,
> if (ret < 0)
> goto done;
> } else {
> - strlcpy(kern_buff, "No testcase executed",
> + strscpy(kern_buff, "No testcase executed",
> XILINX_DPDMA_DEBUGFS_READ_MAX_SIZE);
> }
>
--
Regards,

Laurent Pinchart

2022-07-21 14:14:17

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH] dmaengine: xilinx: use strscpy to replace strlcpy

On 11-07-22, 22:05, XueBing Chen wrote:
>
> The strlcpy should not be used because it doesn't limit the source
> length. Preferred is strscpy.

Applied, thanks

--
~Vinod