Re: [PATCH v2] media: radio: Replace strlcat() with scnprintf() in TEA drivers
From: Alejandro Colomar
Date: Sat Dec 05 2026 - 05:28:41 EST
Hi Mariia,
> Date: 2026-12-04 18:03:33-0800
> From: Mariia Nikitash <nikitash.mariiaw@xxxxxxxxx>
>
> In preparation for removing the deprecated strlcat() API[1],
> replace the strscpy() and strlcat() calls used to construct
> V4L2 card names in the TEA5777 and TEA575x radio drivers.
>
> Construct each card name with a single scnprintf() call, preserving
> the original output and truncation behavior.
>
> Link: https://github.com/KSPP/linux/issues/370 [1]
> Signed-off-by: Mariia Nikitash <nikitash.mariiaw@xxxxxxxxx>
> ---
> Changes in v2:
> - Use scnprintf() instead of seq_buf based on reviewer feedback.
> ---
> drivers/media/radio/radio-tea5777.c | 3 +--
> drivers/media/radio/tea575x.c | 4 ++--
> 2 files changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/radio/radio-tea5777.c b/drivers/media/radio/radio-tea5777.c
> index fb9de7bbcd19..63e7369bedad 100644
> --- a/drivers/media/radio/radio-tea5777.c
> +++ b/drivers/media/radio/radio-tea5777.c
> @@ -257,8 +257,7 @@ static int vidioc_querycap(struct file *file, void *priv,
> struct radio_tea5777 *tea = video_drvdata(file);
>
> strscpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver));
> - strscpy(v->card, tea->card, sizeof(v->card));
> - strlcat(v->card, " TEA5777", sizeof(v->card));
> + scnprintf(v->card, sizeof(v->card), "%s TEA5777", tea->card);
Should we use ARRAY_SIZE() instead of sizeof()? It will make sure that
v->card is actually an array. And since it's a char array, it shouldn't
matter whether we count the number of elements or the size in bytes.
In any case,
Reviewed-by: Alejandro Colomar <alx@xxxxxxxxxx>
Have a lovely day!
Alex
> strscpy(v->bus_info, tea->bus_info, sizeof(v->bus_info));
> return 0;
> }
> diff --git a/drivers/media/radio/tea575x.c b/drivers/media/radio/tea575x.c
> index c37315226c42..9a91ccedcf30 100644
> --- a/drivers/media/radio/tea575x.c
> +++ b/drivers/media/radio/tea575x.c
> @@ -223,8 +223,8 @@ static int vidioc_querycap(struct file *file, void *priv,
> struct snd_tea575x *tea = video_drvdata(file);
>
> strscpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver));
> - strscpy(v->card, tea->card, sizeof(v->card));
> - strlcat(v->card, tea->tea5759 ? " TEA5759" : " TEA5757", sizeof(v->card));
> + scnprintf(v->card, sizeof(v->card), "%s%s", tea->card,
> + tea->tea5759 ? " TEA5759" : " TEA5757");
> strscpy(v->bus_info, tea->bus_info, sizeof(v->bus_info));
> return 0;
> }
>
> ---
> base-commit: 05441d697f7f9a927264f4058cbbc6a03dfcac9d
> change-id: 20261203-strlcat-removal-tea-radio-8a531e00f706
>
--
<https://www.alejandro-colomar.es>
Attachment:
signature.asc
Description: PGP signature