usb: sisusb_con: Use array_size() helper in memcpy()
authorGustavo A. R. Silva <gustavoars@kernel.org>
Mon, 15 Jun 2020 23:18:27 +0000 (18:18 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Jun 2020 08:23:30 +0000 (10:23 +0200)
Use array_size() helper instead of the open-coded version in memcpy().
These sorts of multiplication factors need to be wrapped in array_size().

This issue was found with the help of Coccinelle and, audited and fixed
manually.

Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20200615231827.GA21348@embeddedor
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/misc/sisusbvga/sisusb_con.c

index cd01553..586d6b0 100644 (file)
@@ -1226,7 +1226,7 @@ sisusbcon_font_set(struct vc_data *c, struct console_font *font,
                sisusb->font_backup = vmalloc(array_size(charcount, 32));
 
        if (sisusb->font_backup) {
-               memcpy(sisusb->font_backup, font->data, charcount * 32);
+               memcpy(sisusb->font_backup, font->data, array_size(charcount, 32));
                sisusb->font_backup_size = charcount;
                sisusb->font_backup_height = font->height;
                sisusb->font_backup_512 = (charcount == 512) ? 1 : 0;