staging: gpib: Fix buffer overflow in ni_usb_init

The writes buffer size was not taking into account the number of
entries in the array which was causing random oopses.

Fixes: 4e127de14f ("staging: gpib: Add National Instruments USB GPIB driver")
Signed-off-by: Dave Penkler <dpenkler@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/20241104175014.12317-2-dpenkler@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Dave Penkler 2024-11-04 18:50:02 +01:00 committed by Greg Kroah-Hartman
parent 1235b909d3
commit 8023618a48

View File

@ -1726,7 +1726,7 @@ static int ni_usb_init(gpib_board_t *board)
unsigned int ibsta;
int writes_len;
writes = kmalloc(sizeof(*writes), GFP_KERNEL);
writes = kmalloc_array(NUM_INIT_WRITES, sizeof(*writes), GFP_KERNEL);
if (!writes)
return -ENOMEM;