[PATCH] media: verisilicon: Replace strlcat() with seq_buf
David Laight
david.laight.linux at gmail.com
Sun Nov 8 12:08:00 PST 2026
On Thu, 5 Nov 2026 00:45:18 -0800
Mariia Nikitash <nikitash.mariiaw at gmail.com> wrote:
> In preparation for removing the deprecated strlcat() API[1], replace
> the strscpy() and strlcat() calls with seq_buf operations when
> constructing Hantro video device names.
>
> This preserves the resulting strings, including truncation
> when the compatible string and suffix exceed the destination
> buffer's capacity.
This is just stupid...
David
>
> Link: https://github.com/KSPP/linux/issues/370 [1]
> Signed-off-by: Mariia Nikitash <nikitash.mariiaw at gmail.com>
> ---
> drivers/media/platform/verisilicon/hantro_drv.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
> index 26e5d5547466..2bfcd45cc55e 100644
> --- a/drivers/media/platform/verisilicon/hantro_drv.c
> +++ b/drivers/media/platform/verisilicon/hantro_drv.c
> @@ -17,6 +17,7 @@
> #include <linux/platform_device.h>
> #include <linux/pm.h>
> #include <linux/pm_runtime.h>
> +#include <linux/seq_buf.h>
> #include <linux/slab.h>
> #include <linux/videodev2.h>
> #include <linux/workqueue.h>
> @@ -883,6 +884,7 @@ static int hantro_add_func(struct hantro_dev *vpu, unsigned int funcid)
> const struct of_device_id *match;
> struct hantro_func *func;
> struct video_device *vfd;
> + struct seq_buf s;
> int ret;
>
> match = of_match_node(of_hantro_match, vpu->dev->of_node);
> @@ -902,9 +904,12 @@ static int hantro_add_func(struct hantro_dev *vpu, unsigned int funcid)
> vfd->vfl_dir = VFL_DIR_M2M;
> vfd->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M_MPLANE;
> vfd->ioctl_ops = &hantro_ioctl_ops;
> - strscpy(vfd->name, match->compatible, sizeof(vfd->name));
> - strlcat(vfd->name, funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER ?
> - "-enc" : "-dec", sizeof(vfd->name));
> +
> + seq_buf_init(&s, vfd->name, sizeof(vfd->name));
> + seq_buf_puts(&s, match->compatible);
> + seq_buf_puts(&s, funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER ?
> + "-enc" : "-dec");
> + seq_buf_terminate(&s);
>
> if (funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER) {
> vpu->encoder = func;
More information about the Linux-rockchip
mailing list