serial: Use ARRAY_SIZE() with iso7816 reserved array
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 9 Mar 2023 08:09:16 +0000 (10:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Mar 2023 14:00:40 +0000 (15:00 +0100)
Instead of a literal, size the for loop iteration based on the actual
array using ARRAY_SIZE().

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20230309080923.11778-2-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/serial_core.c

index 2bd32c8ece3939c7baf48f2525ec94c7d6695910..ee2aabcc89433b9277887db12c7516db45bdae58 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/init.h>
 #include <linux/console.h>
 #include <linux/gpio/consumer.h>
+#include <linux/kernel.h>
 #include <linux/of.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
@@ -1491,7 +1492,7 @@ static int uart_set_iso7816_config(struct uart_port *port,
         * There are 5 words reserved for future use. Check that userspace
         * doesn't put stuff in there to prevent breakages in the future.
         */
-       for (i = 0; i < 5; i++)
+       for (i = 0; i < ARRAY_SIZE(iso7816.reserved); i++)
                if (iso7816.reserved[i])
                        return -EINVAL;