1 From 0ad840e46732e95df274a84b042dcb210be9f946 Mon Sep 17 00:00:00 2001
2 From: Roy Pledge <roy.pledge@nxp.com>
3 Date: Thu, 28 Mar 2019 09:56:35 -0400
4 Subject: [PATCH] sdk_qbman: Avoid variable length array in USDPAA
6 As of Linux 5.0 variable length arrays on the stack are no
7 longer allowed. Change to a dynamic array and create a common
8 exit point in the function for cleanup.
10 Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
12 drivers/staging/fsl_qbman/fsl_usdpaa.c | 36 +++++++++++++++++-----------------
13 1 file changed, 18 insertions(+), 18 deletions(-)
15 --- a/drivers/staging/fsl_qbman/fsl_usdpaa.c
16 +++ b/drivers/staging/fsl_qbman/fsl_usdpaa.c
17 @@ -559,6 +559,7 @@ static bool check_portal_channel(void *c
19 static int usdpaa_release(struct inode *inode, struct file *filp)
22 struct ctx *ctx = filp->private_data;
23 struct mem_mapping *map, *tmpmap;
24 struct portal_mapping *portal, *tmpportal;
25 @@ -569,9 +570,14 @@ static int usdpaa_release(struct inode *
26 struct qm_portal_config *qm_alloced_portal = NULL;
27 struct bm_portal_config *bm_alloced_portal = NULL;
29 - struct qm_portal *portal_array[qman_portal_max];
30 + struct qm_portal **portal_array;
33 + portal_array = kmalloc_array(qman_portal_max,
34 + sizeof(struct qm_portal *), GFP_KERNEL);
38 /* Ensure the release operation cannot be migrated to another
39 CPU as CPU specific variables may be needed during cleanup */
40 #ifdef CONFIG_PREEMPT_RT_FULL
41 @@ -612,18 +618,14 @@ static int usdpaa_release(struct inode *
42 qm_alloced_portal = qm_get_unused_portal();
43 if (!qm_alloced_portal) {
44 pr_crit("No QMan portal avalaible for cleanup\n");
45 -#ifdef CONFIG_PREEMPT_RT_FULL
52 qm_cleanup_portal = kmalloc(sizeof(struct qm_portal),
54 if (!qm_cleanup_portal) {
55 -#ifdef CONFIG_PREEMPT_RT_FULL
62 init_qm_portal(qm_alloced_portal, qm_cleanup_portal);
63 portal_array[portal_count] = qm_cleanup_portal;
64 @@ -633,18 +635,14 @@ static int usdpaa_release(struct inode *
65 bm_alloced_portal = bm_get_unused_portal();
66 if (!bm_alloced_portal) {
67 pr_crit("No BMan portal avalaible for cleanup\n");
68 -#ifdef CONFIG_PREEMPT_RT_FULL
75 bm_cleanup_portal = kmalloc(sizeof(struct bm_portal),
77 if (!bm_cleanup_portal) {
78 -#ifdef CONFIG_PREEMPT_RT_FULL
85 init_bm_portal(bm_alloced_portal, bm_cleanup_portal);
87 @@ -721,10 +719,12 @@ static int usdpaa_release(struct inode *
92 #ifdef CONFIG_PREEMPT_RT_FULL
96 + kfree(portal_array);
100 static int check_mmap_dma(struct ctx *ctx, struct vm_area_struct *vma,