]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
staging: media: atomisp: use kmalloc_array() for sh_css_blob_info
authorLin YuChen <starpt.official@gmail.com>
Fri, 13 Mar 2026 17:55:26 +0000 (01:55 +0800)
committerSakari Ailus <sakari.ailus@linux.intel.com>
Wed, 20 May 2026 10:21:40 +0000 (13:21 +0300)
Replace the open-coded multiplication in kmalloc() with kmalloc_array()
to provide overflow protection and improve code readability.

Signed-off-by: Lin YuChen <starpt.official@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
drivers/staging/media/atomisp/pci/sh_css_firmware.c

index 57ecf5549c23d59fece948ac9fb54fb215d5a955..af12df2f9b090a3e8ccb44ff735cbed5b43754d4 100644 (file)
@@ -253,9 +253,9 @@ sh_css_load_firmware(struct device *dev, const char *fw_data,
        sh_css_num_binaries = file_header->binary_nr;
        /* Only allocate memory for ISP blob info */
        if (sh_css_num_binaries > NUM_OF_SPS) {
-               sh_css_blob_info = kmalloc(
-                   (sh_css_num_binaries - NUM_OF_SPS) *
-                   sizeof(*sh_css_blob_info), GFP_KERNEL);
+               sh_css_blob_info =
+                       kmalloc_array(sh_css_num_binaries - NUM_OF_SPS,
+                                     sizeof(*sh_css_blob_info), GFP_KERNEL);
                if (!sh_css_blob_info)
                        return -ENOMEM;
        } else {