aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Pledge <roy.pledge@nxp.com>2019-03-28 09:56:35 -0400
committerDaniel Thompson <daniel@redfelineninja.org.uk>2019-09-17 16:03:05 +0100
commit0a165a19001b41c39cbdf0937dcab89ccc5febb3 (patch)
tree05dabdd725a88becd32b60981c51e5befdee01fa
parentb47e1a3850d394084586ffe5b4efdb6750ababae (diff)
downloadlinux-0a165a19001b41c39cbdf0937dcab89ccc5febb3.tar.gz
sdk_qbman: Avoid variable length array in USDPAA
As of Linux 5.0 variable length arrays on the stack are no longer allowed. Change to a dynamic array and create a common exit point in the function for cleanup. Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
-rw-r--r--drivers/staging/fsl_qbman/fsl_usdpaa.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/staging/fsl_qbman/fsl_usdpaa.c b/drivers/staging/fsl_qbman/fsl_usdpaa.c
index 9dc913706531..a5adcd709819 100644
--- a/drivers/staging/fsl_qbman/fsl_usdpaa.c
+++ b/drivers/staging/fsl_qbman/fsl_usdpaa.c
@@ -560,6 +560,7 @@ static bool check_portal_channel(void *ctx, u32 channel)
static int usdpaa_release(struct inode *inode, struct file *filp)
{
+ int err = 0;
struct ctx *ctx = filp->private_data;
struct mem_mapping *map, *tmpmap;
struct portal_mapping *portal, *tmpportal;
@@ -570,9 +571,14 @@ static int usdpaa_release(struct inode *inode, struct file *filp)
struct qm_portal_config *qm_alloced_portal = NULL;
struct bm_portal_config *bm_alloced_portal = NULL;
- struct qm_portal *portal_array[qman_portal_max];
+ struct qm_portal **portal_array;
int portal_count = 0;
+ portal_array = kmalloc_array(qman_portal_max,
+ sizeof(struct qm_portal *), GFP_KERNEL);
+ if (!portal_array)
+ return -ENOMEM;
+
/* Ensure the release operation cannot be migrated to another
CPU as CPU specific variables may be needed during cleanup */
#ifdef CONFIG_PREEMPT_RT_FULL
@@ -613,18 +619,14 @@ static int usdpaa_release(struct inode *inode, struct file *filp)
qm_alloced_portal = qm_get_unused_portal();
if (!qm_alloced_portal) {
pr_crit("No QMan portal avalaible for cleanup\n");
-#ifdef CONFIG_PREEMPT_RT_FULL
- migrate_enable();
-#endif
- return -1;
+ err = -1;
+ goto done;
}
qm_cleanup_portal = kmalloc(sizeof(struct qm_portal),
GFP_KERNEL);
if (!qm_cleanup_portal) {
-#ifdef CONFIG_PREEMPT_RT_FULL
- migrate_enable();
-#endif
- return -ENOMEM;
+ err = -ENOMEM;
+ goto done;
}
init_qm_portal(qm_alloced_portal, qm_cleanup_portal);
portal_array[portal_count] = qm_cleanup_portal;
@@ -634,18 +636,14 @@ static int usdpaa_release(struct inode *inode, struct file *filp)
bm_alloced_portal = bm_get_unused_portal();
if (!bm_alloced_portal) {
pr_crit("No BMan portal avalaible for cleanup\n");
-#ifdef CONFIG_PREEMPT_RT_FULL
- migrate_enable();
-#endif
- return -1;
+ err = -1;
+ goto done;
}
bm_cleanup_portal = kmalloc(sizeof(struct bm_portal),
GFP_KERNEL);
if (!bm_cleanup_portal) {
-#ifdef CONFIG_PREEMPT_RT_FULL
- migrate_enable();
-#endif
- return -ENOMEM;
+ err = -ENOMEM;
+ goto done;
}
init_bm_portal(bm_alloced_portal, bm_cleanup_portal);
}
@@ -722,10 +720,12 @@ static int usdpaa_release(struct inode *inode, struct file *filp)
}
kfree(ctx);
+done:
#ifdef CONFIG_PREEMPT_RT_FULL
migrate_enable();
#endif
- return 0;
+ kfree(portal_array);
+ return err;
}
static int check_mmap_dma(struct ctx *ctx, struct vm_area_struct *vma,