* [PATCH 1/6] USB: serial: ti_usb_3410_5052: Use safer strscpy() instead of strcpy()
2026-03-10 9:44 [PATCH 0/6] Use safer strscpy() instead of strcpy() Ai Chao
@ 2026-03-10 9:44 ` Ai Chao
2026-03-17 14:37 ` Johan Hovold
2026-03-10 9:44 ` [PATCH 2/6] usb: musb: " Ai Chao
` (4 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Ai Chao @ 2026-03-10 9:44 UTC (permalink / raw)
To: gregkh, b-liu, johan, badhri, heikki.krogerus, valentina.manea.m,
shuah, i, tiwai, kees, christophe.jaillet, prashanth.k, khtsai,
dan.carpenter, tglx, mingo
Cc: linux-usb, linux-kernel, Ai Chao
Use a safer function strscpy() instead of strcpy() for copying to
arrays.
Only idiomatic code replacement, and no functional changes.
Signed-off-by: Ai Chao <aichao@kylinos.cn>
---
drivers/usb/serial/ti_usb_3410_5052.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 658b54d8fcef..b3591d6d7645 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -1600,29 +1600,29 @@ static int ti_download_firmware(struct ti_device *tdev)
if (le16_to_cpu(dev->descriptor.idVendor) == MTS_VENDOR_ID) {
switch (le16_to_cpu(dev->descriptor.idProduct)) {
case MTS_CDMA_PRODUCT_ID:
- strcpy(buf, "mts_cdma.fw");
+ strscpy(buf, "mts_cdma.fw");
break;
case MTS_GSM_PRODUCT_ID:
- strcpy(buf, "mts_gsm.fw");
+ strscpy(buf, "mts_gsm.fw");
break;
case MTS_EDGE_PRODUCT_ID:
- strcpy(buf, "mts_edge.fw");
+ strscpy(buf, "mts_edge.fw");
break;
case MTS_MT9234MU_PRODUCT_ID:
- strcpy(buf, "mts_mt9234mu.fw");
+ strscpy(buf, "mts_mt9234mu.fw");
break;
case MTS_MT9234ZBA_PRODUCT_ID:
- strcpy(buf, "mts_mt9234zba.fw");
+ strscpy(buf, "mts_mt9234zba.fw");
break;
case MTS_MT9234ZBAOLD_PRODUCT_ID:
- strcpy(buf, "mts_mt9234zba.fw");
+ strscpy(buf, "mts_mt9234zba.fw");
break; }
}
if (buf[0] == '\0') {
if (tdev->td_is_3410)
- strcpy(buf, "ti_3410.fw");
+ strscpy(buf, "ti_3410.fw");
else
- strcpy(buf, "ti_5052.fw");
+ strscpy(buf, "ti_5052.fw");
}
status = request_firmware(&fw_p, buf, &dev->dev);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH 1/6] USB: serial: ti_usb_3410_5052: Use safer strscpy() instead of strcpy()
2026-03-10 9:44 ` [PATCH 1/6] USB: serial: ti_usb_3410_5052: " Ai Chao
@ 2026-03-17 14:37 ` Johan Hovold
0 siblings, 0 replies; 13+ messages in thread
From: Johan Hovold @ 2026-03-17 14:37 UTC (permalink / raw)
To: Ai Chao
Cc: gregkh, b-liu, badhri, heikki.krogerus, valentina.manea.m, shuah,
i, tiwai, kees, christophe.jaillet, prashanth.k, khtsai,
dan.carpenter, tglx, mingo, linux-usb, linux-kernel
On Tue, Mar 10, 2026 at 05:44:29PM +0800, Ai Chao wrote:
> Use a safer function strscpy() instead of strcpy() for copying to
> arrays.
>
> Only idiomatic code replacement, and no functional changes.
>
> Signed-off-by: Ai Chao <aichao@kylinos.cn>
> ---
I've applied this one (1/6) for 7.1. Thanks.
Johan
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/6] usb: musb: Use safer strscpy() instead of strcpy()
2026-03-10 9:44 [PATCH 0/6] Use safer strscpy() instead of strcpy() Ai Chao
2026-03-10 9:44 ` [PATCH 1/6] USB: serial: ti_usb_3410_5052: " Ai Chao
@ 2026-03-10 9:44 ` Ai Chao
2026-03-10 9:44 ` [PATCH 3/6] usb: gadget: functionfs: " Ai Chao
` (3 subsequent siblings)
5 siblings, 0 replies; 13+ messages in thread
From: Ai Chao @ 2026-03-10 9:44 UTC (permalink / raw)
To: gregkh, b-liu, johan, badhri, heikki.krogerus, valentina.manea.m,
shuah, i, tiwai, kees, christophe.jaillet, prashanth.k, khtsai,
dan.carpenter, tglx, mingo
Cc: linux-usb, linux-kernel, Ai Chao
Use a safer function strscpy() instead of strcpy() for copying to
arrays.
Only idiomatic code replacement, and no functional changes.
Signed-off-by: Ai Chao <aichao@kylinos.cn>
---
drivers/usb/musb/musb_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 0acc62569ae5..73ac25f53698 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1600,7 +1600,7 @@ static int musb_core_init(u16 musb_type, struct musb *musb)
/* log core options (read using indexed model) */
reg = musb_read_configdata(mbase);
- strcpy(aInfo, (reg & MUSB_CONFIGDATA_UTMIDW) ? "UTMI-16" : "UTMI-8");
+ strscpy(aInfo, (reg & MUSB_CONFIGDATA_UTMIDW) ? "UTMI-16" : "UTMI-8");
if (reg & MUSB_CONFIGDATA_DYNFIFO) {
strcat(aInfo, ", dyn FIFOs");
musb->dyn_fifo = true;
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 3/6] usb: gadget: functionfs: Use safer strscpy() instead of strcpy()
2026-03-10 9:44 [PATCH 0/6] Use safer strscpy() instead of strcpy() Ai Chao
2026-03-10 9:44 ` [PATCH 1/6] USB: serial: ti_usb_3410_5052: " Ai Chao
2026-03-10 9:44 ` [PATCH 2/6] usb: musb: " Ai Chao
@ 2026-03-10 9:44 ` Ai Chao
2026-03-10 9:44 ` [PATCH 4/6] usb: typec: tcpm: " Ai Chao
` (2 subsequent siblings)
5 siblings, 0 replies; 13+ messages in thread
From: Ai Chao @ 2026-03-10 9:44 UTC (permalink / raw)
To: gregkh, b-liu, johan, badhri, heikki.krogerus, valentina.manea.m,
shuah, i, tiwai, kees, christophe.jaillet, prashanth.k, khtsai,
dan.carpenter, tglx, mingo
Cc: linux-usb, linux-kernel, Ai Chao
Use a safer function strscpy() instead of strcpy() for copying to
arrays.
Only idiomatic code replacement, and no functional changes.
Signed-off-by: Ai Chao <aichao@kylinos.cn>
---
drivers/usb/gadget/function/f_midi2.c | 6 +++---
drivers/usb/gadget/function/u_serial.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/gadget/function/f_midi2.c b/drivers/usb/gadget/function/f_midi2.c
index b5f0defde95d..19fdac024343 100644
--- a/drivers/usb/gadget/function/f_midi2.c
+++ b/drivers/usb/gadget/function/f_midi2.c
@@ -1541,9 +1541,9 @@ static int f_midi2_create_card(struct f_midi2 *midi2)
return err;
midi2->card = card;
- strcpy(card->driver, "f_midi2");
- strcpy(card->shortname, "MIDI 2.0 Gadget");
- strcpy(card->longname, "MIDI 2.0 Gadget");
+ strscpy(card->driver, "f_midi2");
+ strscpy(card->shortname, "MIDI 2.0 Gadget");
+ strscpy(card->longname, "MIDI 2.0 Gadget");
id = 0;
for (i = 0; i < midi2->num_eps; i++) {
diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index e43ad6373846..cdd1dfc666c4 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -1086,7 +1086,7 @@ static int gs_console_init(struct gs_port *port)
if (!cons)
return -ENOMEM;
- strcpy(cons->console.name, "ttyGS");
+ strscpy(cons->console.name, "ttyGS");
cons->console.write = gs_console_write;
cons->console.device = gs_console_device;
cons->console.flags = CON_PRINTBUFFER;
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 4/6] usb: typec: tcpm: Use safer strscpy() instead of strcpy()
2026-03-10 9:44 [PATCH 0/6] Use safer strscpy() instead of strcpy() Ai Chao
` (2 preceding siblings ...)
2026-03-10 9:44 ` [PATCH 3/6] usb: gadget: functionfs: " Ai Chao
@ 2026-03-10 9:44 ` Ai Chao
2026-03-10 9:44 ` [PATCH 5/6] usb: gadget: udc: " Ai Chao
2026-03-10 9:44 ` [PATCH 6/6] usbip: vhci_sysfs: " Ai Chao
5 siblings, 0 replies; 13+ messages in thread
From: Ai Chao @ 2026-03-10 9:44 UTC (permalink / raw)
To: gregkh, b-liu, johan, badhri, heikki.krogerus, valentina.manea.m,
shuah, i, tiwai, kees, christophe.jaillet, prashanth.k, khtsai,
dan.carpenter, tglx, mingo
Cc: linux-usb, linux-kernel, Ai Chao
Use a safer function strscpy() instead of strcpy() for copying to
arrays.
Only idiomatic code replacement, and no functional changes.
Signed-off-by: Ai Chao <aichao@kylinos.cn>
---
drivers/usb/typec/tcpm/tcpm.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 1d2f3af034c5..8d939ffb9ac7 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -725,7 +725,7 @@ static void _tcpm_log(struct tcpm_port *port, const char *fmt, va_list args)
if (tcpm_log_full(port)) {
port->logbuffer_head = max(port->logbuffer_head - 1, 0);
- strcpy(tmpbuffer, "overflow");
+ strscpy(tmpbuffer, "overflow");
}
if (port->logbuffer_head < 0 ||
@@ -841,10 +841,10 @@ static void tcpm_log_source_caps(struct tcpm_port *port)
pdo_spr_avs_apdo_15v_to_20v_max_current_ma(pdo),
pdo_spr_avs_apdo_src_peak_current(pdo));
else
- strcpy(msg, "undefined APDO");
+ strscpy(msg, "undefined APDO");
break;
default:
- strcpy(msg, "undefined");
+ strscpy(msg, "undefined");
break;
}
tcpm_log(port, " PDO %d: type %d, %s",
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 5/6] usb: gadget: udc: Use safer strscpy() instead of strcpy()
2026-03-10 9:44 [PATCH 0/6] Use safer strscpy() instead of strcpy() Ai Chao
` (3 preceding siblings ...)
2026-03-10 9:44 ` [PATCH 4/6] usb: typec: tcpm: " Ai Chao
@ 2026-03-10 9:44 ` Ai Chao
2026-03-10 9:44 ` [PATCH 6/6] usbip: vhci_sysfs: " Ai Chao
5 siblings, 0 replies; 13+ messages in thread
From: Ai Chao @ 2026-03-10 9:44 UTC (permalink / raw)
To: gregkh, b-liu, johan, badhri, heikki.krogerus, valentina.manea.m,
shuah, i, tiwai, kees, christophe.jaillet, prashanth.k, khtsai,
dan.carpenter, tglx, mingo
Cc: linux-usb, linux-kernel, Ai Chao
Use a safer function strscpy() instead of strcpy() for copying to
arrays.
Only idiomatic code replacement, and no functional changes.
Signed-off-by: Ai Chao <aichao@kylinos.cn>
---
drivers/usb/gadget/udc/snps_udc_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/udc/snps_udc_core.c b/drivers/usb/gadget/udc/snps_udc_core.c
index 5f9514623956..0e0db68e0b27 100644
--- a/drivers/usb/gadget/udc/snps_udc_core.c
+++ b/drivers/usb/gadget/udc/snps_udc_core.c
@@ -3151,7 +3151,7 @@ int udc_probe(struct udc *dev)
tmp, dev->phys_addr, dev->chiprev,
(dev->chiprev == UDC_HSA0_REV) ?
"A0" : "B1");
- strcpy(tmp, UDC_DRIVER_VERSION_STRING);
+ strscpy(tmp, UDC_DRIVER_VERSION_STRING);
if (dev->chiprev == UDC_HSA0_REV) {
dev_err(dev->dev, "chip revision is A0; too old\n");
retval = -ENODEV;
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 6/6] usbip: vhci_sysfs: Use safer strscpy() instead of strcpy()
2026-03-10 9:44 [PATCH 0/6] Use safer strscpy() instead of strcpy() Ai Chao
` (4 preceding siblings ...)
2026-03-10 9:44 ` [PATCH 5/6] usb: gadget: udc: " Ai Chao
@ 2026-03-10 9:44 ` Ai Chao
2026-03-10 22:10 ` Shuah Khan
5 siblings, 1 reply; 13+ messages in thread
From: Ai Chao @ 2026-03-10 9:44 UTC (permalink / raw)
To: gregkh, b-liu, johan, badhri, heikki.krogerus, valentina.manea.m,
shuah, i, tiwai, kees, christophe.jaillet, prashanth.k, khtsai,
dan.carpenter, tglx, mingo
Cc: linux-usb, linux-kernel, Ai Chao
Use a safer function strscpy() instead of strcpy() for copying to
arrays.
Only idiomatic code replacement, and no functional changes.
Signed-off-by: Ai Chao <aichao@kylinos.cn>
---
drivers/usb/usbip/vhci_sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
index bfc10f665e52..5bc8c47788d4 100644
--- a/drivers/usb/usbip/vhci_sysfs.c
+++ b/drivers/usb/usbip/vhci_sysfs.c
@@ -463,7 +463,7 @@ static void set_status_attr(int id)
status = status_attrs + id;
if (id == 0)
- strcpy(status->name, "status");
+ strscpy(status->name, "status");
else
snprintf(status->name, MAX_STATUS_NAME+1, "status.%d", id);
status->attr.attr.name = status->name;
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH 6/6] usbip: vhci_sysfs: Use safer strscpy() instead of strcpy()
2026-03-10 9:44 ` [PATCH 6/6] usbip: vhci_sysfs: " Ai Chao
@ 2026-03-10 22:10 ` Shuah Khan
2026-03-11 7:22 ` Dan Carpenter
0 siblings, 1 reply; 13+ messages in thread
From: Shuah Khan @ 2026-03-10 22:10 UTC (permalink / raw)
To: Ai Chao, gregkh, b-liu, johan, badhri, heikki.krogerus,
valentina.manea.m, shuah, i, tiwai, kees, christophe.jaillet,
prashanth.k, khtsai, dan.carpenter, tglx, mingo
Cc: linux-usb, linux-kernel, Shuah Khan
On 3/10/26 03:44, Ai Chao wrote:
> Use a safer function strscpy() instead of strcpy() for copying to
> arrays.
>
> Only idiomatic code replacement, and no functional changes.
It is a functional change since it calls a new routine. Get rid
of this line from change log.
How did you test this patch? I am curious because of you are
describing the change as "idiomatic code replacement"
>
> Signed-off-by: Ai Chao <aichao@kylinos.cn>
> ---
> drivers/usb/usbip/vhci_sysfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
> index bfc10f665e52..5bc8c47788d4 100644
> --- a/drivers/usb/usbip/vhci_sysfs.c
> +++ b/drivers/usb/usbip/vhci_sysfs.c
> @@ -463,7 +463,7 @@ static void set_status_attr(int id)
>
> status = status_attrs + id;
> if (id == 0)
> - strcpy(status->name, "status");
> + strscpy(status->name, "status");
> else
> snprintf(status->name, MAX_STATUS_NAME+1, "status.%d", id);
> status->attr.attr.name = status->name;
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 6/6] usbip: vhci_sysfs: Use safer strscpy() instead of strcpy()
2026-03-10 22:10 ` Shuah Khan
@ 2026-03-11 7:22 ` Dan Carpenter
2026-03-24 21:34 ` Shuah Khan
0 siblings, 1 reply; 13+ messages in thread
From: Dan Carpenter @ 2026-03-11 7:22 UTC (permalink / raw)
To: Shuah Khan
Cc: Ai Chao, gregkh, b-liu, johan, badhri, heikki.krogerus,
valentina.manea.m, shuah, i, tiwai, kees, christophe.jaillet,
prashanth.k, khtsai, tglx, mingo, linux-usb, linux-kernel
On Tue, Mar 10, 2026 at 04:10:20PM -0600, Shuah Khan wrote:
> On 3/10/26 03:44, Ai Chao wrote:
> > Use a safer function strscpy() instead of strcpy() for copying to
> > arrays.
> >
> > Only idiomatic code replacement, and no functional changes.
>
> It is a functional change since it calls a new routine. Get rid
> of this line from change log.
>
> How did you test this patch? I am curious because of you are
> describing the change as "idiomatic code replacement"
>
I liked the commit message... To me it says that patch affect
runtime. It doesn' fix any bugs or introduce any bugs. Too often
these changes are sold as a "potential" bugfix, which means people
haven't bothered to check whether it fixes a bug or not.
It's the right thing to add a note under the --- cut off that the
patch hasn't been tested. Testing isn't required for this sort
of patch but a note is good so reviewers will know to be careful.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 6/6] usbip: vhci_sysfs: Use safer strscpy() instead of strcpy()
2026-03-11 7:22 ` Dan Carpenter
@ 2026-03-24 21:34 ` Shuah Khan
2026-03-25 11:09 ` Dan Carpenter
0 siblings, 1 reply; 13+ messages in thread
From: Shuah Khan @ 2026-03-24 21:34 UTC (permalink / raw)
To: Dan Carpenter
Cc: Ai Chao, gregkh, b-liu, johan, badhri, heikki.krogerus,
valentina.manea.m, shuah, i, tiwai, kees, christophe.jaillet,
prashanth.k, khtsai, tglx, mingo, linux-usb, linux-kernel,
Shuah Khan
On 3/11/26 01:22, Dan Carpenter wrote:
> On Tue, Mar 10, 2026 at 04:10:20PM -0600, Shuah Khan wrote:
>> On 3/10/26 03:44, Ai Chao wrote:
>>> Use a safer function strscpy() instead of strcpy() for copying to
>>> arrays.
>>>
>>> Only idiomatic code replacement, and no functional changes.
>>
>> It is a functional change since it calls a new routine. Get rid
>> of this line from change log.
>>
>> How did you test this patch? I am curious because of you are
>> describing the change as "idiomatic code replacement"
>>
>
> I liked the commit message... To me it says that patch affect
> runtime. It doesn' fix any bugs or introduce any bugs. Too often
> these changes are sold as a "potential" bugfix, which means people
> haven't bothered to check whether it fixes a bug or not.
>
> It's the right thing to add a note under the --- cut off that the
> patch hasn't been tested. Testing isn't required for this sort
> of patch but a note is good so reviewers will know to be careful.
I would like to see some sort of testing for patches like this one.
It isn't hard to test this change.
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 6/6] usbip: vhci_sysfs: Use safer strscpy() instead of strcpy()
2026-03-24 21:34 ` Shuah Khan
@ 2026-03-25 11:09 ` Dan Carpenter
0 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2026-03-25 11:09 UTC (permalink / raw)
To: Shuah Khan
Cc: Ai Chao, gregkh, b-liu, johan, badhri, heikki.krogerus,
valentina.manea.m, shuah, i, tiwai, kees, christophe.jaillet,
prashanth.k, khtsai, tglx, mingo, linux-usb, linux-kernel
On Tue, Mar 24, 2026 at 03:34:03PM -0600, Shuah Khan wrote:
> On 3/11/26 01:22, Dan Carpenter wrote:
> > On Tue, Mar 10, 2026 at 04:10:20PM -0600, Shuah Khan wrote:
> > > On 3/10/26 03:44, Ai Chao wrote:
> > > > Use a safer function strscpy() instead of strcpy() for copying to
> > > > arrays.
> > > >
> > > > Only idiomatic code replacement, and no functional changes.
> > >
> > > It is a functional change since it calls a new routine. Get rid
> > > of this line from change log.
> > >
> > > How did you test this patch? I am curious because of you are
> > > describing the change as "idiomatic code replacement"
> > >
> >
> > I liked the commit message... To me it says that patch affect
> > runtime. It doesn' fix any bugs or introduce any bugs. Too often
> > these changes are sold as a "potential" bugfix, which means people
> > haven't bothered to check whether it fixes a bug or not.
> >
> > It's the right thing to add a note under the --- cut off that the
> > patch hasn't been tested. Testing isn't required for this sort
> > of patch but a note is good so reviewers will know to be careful.
>
> I would like to see some sort of testing for patches like this one.
> It isn't hard to test this change.
It would take me a while to figure out how to test this. :P Presumably,
it's:
sudo ./tools/testing/selftests/drivers/usb/usbip/usbip_test.sh -b<busid> -p tools/usb/usbip/
but I couldn't figure out what to supply for a busid... Does
kernel-ci do usbip testing?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 13+ messages in thread