usb: gadget: serial: reject port counts exceeding the array size
PATCH 1/1 usb: gadget: serial: reject port counts exceeding the array size
The n_ports module parameter has no upper bound check, while fi_serial and f_serial each contain only MAX_U_SERIAL_PORTS entries.
Reject n_ports values greater than MAX_U_SERIAL_PORTS in gserial_init(), before registering the composite driver.
Signed-off-by Ju Nan <[email protected]>
--- drivers/usb/gadget/legacy/serial.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/gadget/legacy/serial.c +3 -0
@@ -286,6 +286,9 @@ static int switch_gserial_enable(bool do_enable)static int __init gserial_init (void ) { +if (n_ports >MAX_U_SERIAL_PORTS ) +return -EINVAL ; +/* We *could* export two configs; that'd be much cleaner... * but neither of these product IDs was defined that way. */
Signature · 1 line
2.56.1
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 7 lines
The
n_portsmodule parameter has no upper bound check, whilefi_serialandf_serialeach contain onlyMAX_U_SERIAL_PORTSentries.Reject
n_portsvalues greater thanMAX_U_SERIAL_PORTSingserial_init(), before registering the composite driver.Signed-off-by Ju Nan <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1