diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/fsl_qbman/bman_driver.c | 4 | ||||
-rw-r--r-- | drivers/staging/fsl_qbman/dpa_alloc.c | 2 | ||||
-rw-r--r-- | drivers/staging/fsl_qbman/fsl_usdpaa.c | 14 | ||||
-rw-r--r-- | drivers/staging/fsl_qbman/qman_driver.c | 4 | ||||
-rw-r--r-- | drivers/staging/fsl_qbman/qman_high.c | 54 | ||||
-rw-r--r-- | drivers/staging/fsl_qbman/qman_low.h | 3 |
6 files changed, 68 insertions, 13 deletions
diff --git a/drivers/staging/fsl_qbman/bman_driver.c b/drivers/staging/fsl_qbman/bman_driver.c index 7ef20e3..2eb590f 100644 --- a/drivers/staging/fsl_qbman/bman_driver.c +++ b/drivers/staging/fsl_qbman/bman_driver.c @@ -468,6 +468,10 @@ __init int bman_init(void) list_for_each_entry(pcfg, &unshared_pcfgs, list) { pcfg->public_cfg.is_shared = 0; p = init_pcfg(pcfg); + if (!p) { + pr_crit("Unable to initialize bman portal\n"); + return 0; + } } /* Step 5. */ list_for_each_entry(pcfg, &shared_pcfgs, list) { diff --git a/drivers/staging/fsl_qbman/dpa_alloc.c b/drivers/staging/fsl_qbman/dpa_alloc.c index 2468a97..44db3e1 100644 --- a/drivers/staging/fsl_qbman/dpa_alloc.c +++ b/drivers/staging/fsl_qbman/dpa_alloc.c @@ -500,6 +500,8 @@ done: *result = base; } else { spin_unlock_irq(&alloc->lock); + kfree(margin_left); + kfree(margin_right); } err: diff --git a/drivers/staging/fsl_qbman/fsl_usdpaa.c b/drivers/staging/fsl_qbman/fsl_usdpaa.c index 5f2459f..9965e4a 100644 --- a/drivers/staging/fsl_qbman/fsl_usdpaa.c +++ b/drivers/staging/fsl_qbman/fsl_usdpaa.c @@ -759,6 +759,9 @@ static unsigned long usdpaa_get_unmapped_area(struct file *file, will be correctly aligned */ len = largest_page_size(len); + if (!len) + return -EINVAL; + addr = USDPAA_MEM_ROUNDUP(addr, len); vma = find_vma(current->mm, addr); /* Keep searching until we reach the end of currently-used virtual @@ -908,7 +911,8 @@ static long ioctl_dma_map(struct file *fp, struct ctx *ctx, int frag_count = 0; unsigned long next_addr = PAGE_SIZE, populate; - if (i->len && i->len % PAGE_SIZE) + /* error checking to ensure values copied from user space are valid */ + if (!i->len || (i->len % PAGE_SIZE)) return -EINVAL; map = kmalloc(sizeof(*map), GFP_KERNEL); @@ -1039,8 +1043,14 @@ do_map: struct mem_fragment, list); } if (i->did_create) { + size_t name_len = 0; start_frag->flags = i->flags; strncpy(start_frag->name, i->name, USDPAA_DMA_NAME_MAX); + name_len = strnlen(start_frag->name, USDPAA_DMA_NAME_MAX); + if (name_len >= USDPAA_DMA_NAME_MAX) { + ret = -EFAULT; + goto out; + } start_frag->map_len = i->len; start_frag->has_locking = i->has_locking; init_waitqueue_head(&start_frag->wq); @@ -1188,6 +1198,8 @@ map_match: spin_unlock(&mem_lock); up_read(¤t->mm->mmap_sem); + if (!map) + return -EFAULT; if (!map->root_frag->has_locking) return -ENODEV; return wait_event_interruptible(map->root_frag->wq, test_lock(map)); diff --git a/drivers/staging/fsl_qbman/qman_driver.c b/drivers/staging/fsl_qbman/qman_driver.c index d74369b..983f99a 100644 --- a/drivers/staging/fsl_qbman/qman_driver.c +++ b/drivers/staging/fsl_qbman/qman_driver.c @@ -855,6 +855,10 @@ __init int qman_init(void) list_for_each_entry(pcfg, &unshared_pcfgs, list) { pcfg->public_cfg.is_shared = 0; p = init_pcfg(pcfg); + if (!p) { + pr_crit("Unable to configure portals\n"); + return 0; + } } list_for_each_entry(pcfg, &shared_pcfgs, list) { pcfg->public_cfg.is_shared = 1; diff --git a/drivers/staging/fsl_qbman/qman_high.c b/drivers/staging/fsl_qbman/qman_high.c index 8d3011e..374ebf6 100644 --- a/drivers/staging/fsl_qbman/qman_high.c +++ b/drivers/staging/fsl_qbman/qman_high.c @@ -547,6 +547,10 @@ struct qman_portal *qman_create_portal( /* special handling, drain just in case it's a few FQRNIs */ if (drain_mr_fqrni(__p)) { const struct qm_mr_entry *e = qm_mr_current(__p); + /* + * Message ring cannot be empty no need to check + * qm_mr_current returned successfully + */ pr_err("Qman MR unclean, MR VERB 0x%x, " "rc 0x%x\n, addr 0x%x", e->verb, e->ern.rc, e->ern.fd.addr_lo); @@ -585,6 +589,8 @@ fail_mr: fail_dqrr: qm_eqcr_finish(__p); fail_eqcr: + if (portal->alloced) + kfree(portal); return NULL; } @@ -3706,10 +3712,16 @@ int qman_ceetm_channel_claim(struct qm_ceetm_channel **channel, struct qm_mcc_ceetm_mapping_shaper_tcfc_config config_opts; static u8 map; - if (lni->dcp_idx == qm_dc_portal_fman0) + if (lni->dcp_idx == qm_dc_portal_fman0) { ret = qman_alloc_ceetm0_channel(&channel_idx); - if (lni->dcp_idx == qm_dc_portal_fman1) + } else if (lni->dcp_idx == qm_dc_portal_fman1) { ret = qman_alloc_ceetm1_channel(&channel_idx); + } else { + pr_err("dcp_idx %u does not correspond to a known fman in this driver\n", + lni->dcp_idx); + return -EINVAL; + } + if (ret) { pr_err("The is no channel available for LNI#%d\n", lni->idx); return -ENODEV; @@ -3750,6 +3762,14 @@ int qman_ceetm_channel_release(struct qm_ceetm_channel *channel) return -EBUSY; } + /* channel->dcp_idx corresponds to known fman validation */ + if ((channel->dcp_idx != qm_dc_portal_fman0) && + (channel->dcp_idx != qm_dc_portal_fman1)) { + pr_err("dcp_idx %u does not correspond to a known fman in this driver\n", + channel->dcp_idx); + return -EINVAL; + } + config_opts.cid = CEETM_COMMAND_CHANNEL_SHAPER | channel->idx; config_opts.dcpid = channel->dcp_idx; memset(&config_opts.shaper_config, 0, @@ -3759,10 +3779,15 @@ int qman_ceetm_channel_release(struct qm_ceetm_channel *channel) return -EINVAL; } - if (channel->dcp_idx == qm_dc_portal_fman0) + if (channel->dcp_idx == qm_dc_portal_fman0) { qman_release_ceetm0_channelid(channel->idx); - if (channel->dcp_idx == qm_dc_portal_fman1) + } else if (channel->dcp_idx == qm_dc_portal_fman1) { qman_release_ceetm1_channelid(channel->idx); + } else { + pr_err("dcp_idx %u does not correspond to a known fman in this driver\n", + channel->dcp_idx); + return -EINVAL; + } list_del(&channel->node); kfree(channel); @@ -4518,10 +4543,16 @@ int qman_ceetm_lfq_claim(struct qm_ceetm_lfq **lfq, int ret = 0; struct qm_mcc_ceetm_lfqmt_config lfqmt_config; - if (cq->parent->dcp_idx == qm_dc_portal_fman0) + if (cq->parent->dcp_idx == qm_dc_portal_fman0) { ret = qman_alloc_ceetm0_lfqid(&lfqid); - if (cq->parent->dcp_idx == qm_dc_portal_fman1) + } else if (cq->parent->dcp_idx == qm_dc_portal_fman1) { ret = qman_alloc_ceetm1_lfqid(&lfqid); + } else { + pr_err("dcp_idx %u does not correspond to a known fman in this driver\n", + cq->parent->dcp_idx); + return -EINVAL; + } + if (ret) { pr_err("There is no lfqid avalaible for CQ#%d!\n", cq->idx); return -ENODEV; @@ -4551,10 +4582,15 @@ EXPORT_SYMBOL(qman_ceetm_lfq_claim); int qman_ceetm_lfq_release(struct qm_ceetm_lfq *lfq) { - if (lfq->parent->dcp_idx == qm_dc_portal_fman0) + if (lfq->parent->dcp_idx == qm_dc_portal_fman0) { qman_release_ceetm0_lfqid(lfq->idx); - if (lfq->parent->dcp_idx == qm_dc_portal_fman1) + } else if (lfq->parent->dcp_idx == qm_dc_portal_fman1) { qman_release_ceetm1_lfqid(lfq->idx); + } else { + pr_err("dcp_idx %u does not correspond to a known fman in this driver\n", + lfq->parent->dcp_idx); + return -EINVAL; + } list_del(&lfq->node); kfree(lfq); return 0; @@ -4618,7 +4654,7 @@ int qman_ceetm_ccg_claim(struct qm_ceetm_ccg **ccg, { struct qm_ceetm_ccg *p; - if ((idx < 0) || (idx > 15)) { + if (idx > 15) { pr_err("The given ccg index is out of range\n"); return -EINVAL; } diff --git a/drivers/staging/fsl_qbman/qman_low.h b/drivers/staging/fsl_qbman/qman_low.h index 5d3e820..2fe7a1e 100644 --- a/drivers/staging/fsl_qbman/qman_low.h +++ b/drivers/staging/fsl_qbman/qman_low.h @@ -1339,9 +1339,6 @@ static inline int qm_shutdown_fq(struct qm_portal **portal, int portal_count, return -1; } return 0; - case QM_MCR_NP_STATE_OOS: - /* Done */ - return 0; } return -1; } |