[PATCH] USB: misc: adutux: use kmalloc_array() for read buffers

From: Can Peng

Date: Tue Jun 23 2026 - 03:22:50 EST


Use kmalloc_array() for the primary and secondary read buffers. Each
buffer stores four interrupt-in endpoint packets, so express the
allocation as 4 elements of in_end_size bytes and avoid open-coded
multiplication in allocator arguments.

Signed-off-by: Can Peng <pengcan@xxxxxxxxxx>
---
drivers/usb/misc/adutux.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index 369d0d2ee2be..7615cb6bb482 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -680,7 +680,7 @@ static int adu_probe(struct usb_interface *interface,
in_end_size = usb_endpoint_maxp(dev->interrupt_in_endpoint);
out_end_size = usb_endpoint_maxp(dev->interrupt_out_endpoint);

- dev->read_buffer_primary = kmalloc((4 * in_end_size), GFP_KERNEL);
+ dev->read_buffer_primary = kmalloc_array(4, in_end_size, GFP_KERNEL);
if (!dev->read_buffer_primary)
goto error;

@@ -690,7 +690,7 @@ static int adu_probe(struct usb_interface *interface,
memset(dev->read_buffer_primary + (2 * in_end_size), 'c', in_end_size);
memset(dev->read_buffer_primary + (3 * in_end_size), 'd', in_end_size);

- dev->read_buffer_secondary = kmalloc((4 * in_end_size), GFP_KERNEL);
+ dev->read_buffer_secondary = kmalloc_array(4, in_end_size, GFP_KERNEL);
if (!dev->read_buffer_secondary)
goto error;

--
2.53.0