]> www.infradead.org Git - linux.git/commitdiff
driver core: platform: Switch to use kmemdup_array()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 6 Jun 2024 16:49:26 +0000 (19:49 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Jul 2024 10:02:38 +0000 (12:02 +0200)
Let the kememdup_array() take care about multiplication and possible
overflows.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240606164926.3031358-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/platform.c

index 8a511fe47bdba200558347f88b8738beb805bd9b..4c3ee6521ba5f2a9f34e7ea9a562fb0d784f3514 100644 (file)
@@ -608,7 +608,7 @@ int platform_device_add_resources(struct platform_device *pdev,
        struct resource *r = NULL;
 
        if (res) {
-               r = kmemdup(res, sizeof(struct resource) * num, GFP_KERNEL);
+               r = kmemdup_array(res, num, sizeof(*r), GFP_KERNEL);
                if (!r)
                        return -ENOMEM;
        }