mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: verisilicon: Replace strlcat() with seq_buf
@ 2026-11-05  8:45 Mariia Nikitash
  2026-11-08 20:08 ` David Laight
  2026-11-11  3:24 ` [PATCH v2] media: verisilicon: Replace strlcat() with scnprintf() Mariia Nikitash
  0 siblings, 2 replies; 5+ messages in thread
From: Mariia Nikitash @ 2026-11-05  8:45 UTC (permalink / raw)
  To: nicolas.dufresne, benjamin.gaignard, p.zabel
  Cc: mchehab, linux-media, linux-rockchip, linux-kernel,
	linux-hardening, kees, justinstitt, morbo, Mariia Nikitash

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.

Link: https://github.com/KSPP/linux/issues/370 [1]
Signed-off-by: Mariia Nikitash <nikitash.mariiaw@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;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] media: verisilicon: Replace strlcat() with seq_buf
  2026-11-05  8:45 [PATCH] media: verisilicon: Replace strlcat() with seq_buf Mariia Nikitash
@ 2026-11-08 20:08 ` David Laight
  2026-11-10 10:13   ` Hans Verkuil
  2026-11-11  3:24 ` [PATCH v2] media: verisilicon: Replace strlcat() with scnprintf() Mariia Nikitash
  1 sibling, 1 reply; 5+ messages in thread
From: David Laight @ 2026-11-08 20:08 UTC (permalink / raw)
  To: Mariia Nikitash
  Cc: nicolas.dufresne, benjamin.gaignard, p.zabel, mchehab,
	linux-media, linux-rockchip, linux-kernel, linux-hardening, kees,
	justinstitt, morbo

On Thu,  5 Nov 2026 00:45:18 -0800
Mariia Nikitash <nikitash.mariiaw@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@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;


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] media: verisilicon: Replace strlcat() with seq_buf
  2026-11-08 20:08 ` David Laight
@ 2026-11-10 10:13   ` Hans Verkuil
  2026-11-10 18:27     ` Mariia Nikitash
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Verkuil @ 2026-11-10 10:13 UTC (permalink / raw)
  To: David Laight, Mariia Nikitash
  Cc: nicolas.dufresne, benjamin.gaignard, p.zabel, mchehab,
	linux-media, linux-rockchip, linux-kernel, linux-hardening, kees,
	justinstitt, morbo

On 08/11/2026 21:08, David Laight wrote:
> On Thu,  5 Nov 2026 00:45:18 -0800
> Mariia Nikitash <nikitash.mariiaw@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@gmail.com>

Nacked-by: Hans Verkuil <hverkuil+cisco@kernel.org>

Just use scnprintf.

Regards,

	Hans

>> ---
>>  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;
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] media: verisilicon: Replace strlcat() with seq_buf
  2026-11-10 10:13   ` Hans Verkuil
@ 2026-11-10 18:27     ` Mariia Nikitash
  0 siblings, 0 replies; 5+ messages in thread
From: Mariia Nikitash @ 2026-11-10 18:27 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: David Laight, nicolas.dufresne, benjamin.gaignard, p.zabel,
	mchehab, linux-media, linux-rockchip, linux-kernel,
	linux-hardening, kees, justinstitt, morbo

On Tue, Nov 10, 2026 at 2:13 AM Hans Verkuil <hverkuil+cisco@kernel.org> wrote:
>
> On 08/11/2026 21:08, David Laight wrote:
> > On Thu,  5 Nov 2026 00:45:18 -0800
> > Mariia Nikitash <nikitash.mariiaw@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@gmail.com>
>
> Nacked-by: Hans Verkuil <hverkuil+cisco@kernel.org>
>
> Just use scnprintf.

Thanks for the reviews, I will simplify it to use scnprintf and send a v2.
>
> Regards,
>
>         Hans
>

Best,
Mariia
> >> ---
> >>  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;
> >
> >
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] media: verisilicon: Replace strlcat() with scnprintf()
  2026-11-05  8:45 [PATCH] media: verisilicon: Replace strlcat() with seq_buf Mariia Nikitash
  2026-11-08 20:08 ` David Laight
@ 2026-11-11  3:24 ` Mariia Nikitash
  1 sibling, 0 replies; 5+ messages in thread
From: Mariia Nikitash @ 2026-11-11  3:24 UTC (permalink / raw)
  To: nicolas.dufresne, benjamin.gaignard, p.zabel
  Cc: mchehab, hverkuil+cisco, linux-media, linux-rockchip,
	linux-kernel, linux-hardening, kees, justinstitt, morbo,
	david.laight.linux, Mariia Nikitash

In preparation for removing the deprecated strlcat() API [1], replace the
strscpy() and strlcat() calls in hantro_add_func() with a single
scnprintf() call.

This preserves the resulting string, including NUL termination
and truncation behavior.

Link: https://github.com/KSPP/linux/issues/370 [1]
Signed-off-by: Mariia Nikitash <nikitash.mariiaw@gmail.com>
---
Changes in v2:
- Replace seq_buf with a single scnprintf() call, as suggested
  by Hans Verkuil.

 drivers/media/platform/verisilicon/hantro_drv.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 26e5d5547466..d8854ceb4fed 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -902,9 +902,8 @@ 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));
+	scnprintf(vfd->name, sizeof(vfd->name), "%s%s", match->compatible,
+		  funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER ? "-enc" : "-dec");
 
 	if (funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER) {
 		vpu->encoder = func;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-11  3:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-05  8:45 [PATCH] media: verisilicon: Replace strlcat() with seq_buf Mariia Nikitash
2026-11-08 20:08 ` David Laight
2026-11-10 10:13   ` Hans Verkuil
2026-11-10 18:27     ` Mariia Nikitash
2026-11-11  3:24 ` [PATCH v2] media: verisilicon: Replace strlcat() with scnprintf() Mariia Nikitash

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®