]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ACPI/IORT: Switch to use kmemdup_array()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 6 Jun 2024 16:50:05 +0000 (19:50 +0300)
committerWill Deacon <will@kernel.org>
Fri, 16 Aug 2024 10:33:15 +0000 (11:33 +0100)
Let the kememdup_array() take care about multiplication and possible
overflows.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Hanjun Guo <guohanjun@huawei.com>
Link: https://lore.kernel.org/r/20240606165005.3031490-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/acpi/arm64/iort.c

index 1b39e9ae7ac1788c49fa2501242ffab865344a70..034d303c3df147cdc63da2bc246b5cb73408a5f2 100644 (file)
@@ -822,7 +822,7 @@ static struct iommu_iort_rmr_data *iort_rmr_alloc(
                return NULL;
 
        /* Create a copy of SIDs array to associate with this rmr_data */
-       sids_copy = kmemdup(sids, num_sids * sizeof(*sids), GFP_KERNEL);
+       sids_copy = kmemdup_array(sids, num_sids, sizeof(*sids), GFP_KERNEL);
        if (!sids_copy) {
                kfree(rmr_data);
                return NULL;