hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/mtd/maps/sa1100-flash.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Flash memory access on SA11x0 based devices
34 *
....@@ -20,7 +21,7 @@
2021 #include <linux/mtd/concat.h>
2122
2223 #include <mach/hardware.h>
23
-#include <asm/sizes.h>
24
+#include <linux/sizes.h>
2425 #include <asm/mach/flash.h>
2526
2627 struct sa_subdev_info {
....@@ -33,7 +34,7 @@
3334 struct sa_info {
3435 struct mtd_info *mtd;
3536 int num_subdev;
36
- struct sa_subdev_info subdev[0];
37
+ struct sa_subdev_info subdev[];
3738 };
3839
3940 static DEFINE_SPINLOCK(sa1100_vpp_lock);
....@@ -80,7 +81,7 @@
8081 default:
8182 printk(KERN_WARNING "SA1100 flash: unknown base address "
8283 "0x%08lx, assuming CS0\n", phys);
83
-
84
+ fallthrough;
8485 case SA1100_CS0_PHYS:
8586 subdev->map.bankwidth = (MSC0 & MSC_RBW) ? 2 : 4;
8687 break;
....@@ -221,7 +222,14 @@
221222 info->mtd = info->subdev[0].mtd;
222223 ret = 0;
223224 } else if (info->num_subdev > 1) {
224
- struct mtd_info *cdev[nr];
225
+ struct mtd_info **cdev;
226
+
227
+ cdev = kmalloc_array(nr, sizeof(*cdev), GFP_KERNEL);
228
+ if (!cdev) {
229
+ ret = -ENOMEM;
230
+ goto err;
231
+ }
232
+
225233 /*
226234 * We detected multiple devices. Concatenate them together.
227235 */
....@@ -230,6 +238,7 @@
230238
231239 info->mtd = mtd_concat_create(cdev, info->num_subdev,
232240 plat->name);
241
+ kfree(cdev);
233242 if (info->mtd == NULL) {
234243 ret = -ENXIO;
235244 goto err;