soc: qcom: hab: resolve NULL pointer dereference issues
Some NULL pointer dereference issues are fixed. Change-Id: I0f7f8ede860c81d451f2105520750692fd4eee50 Signed-off-by: Yong Ding <yongding@codeaurora.org>
This commit is contained in:
parent
cd536e63e3
commit
a16a7501c8
2 changed files with 13 additions and 11 deletions
|
@ -361,18 +361,19 @@ static int hab_map_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||||
{
|
{
|
||||||
struct page *page;
|
struct page *page;
|
||||||
struct pages_list *pglist;
|
struct pages_list *pglist;
|
||||||
|
unsigned long offset, fault_offset, fault_index;
|
||||||
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
|
|
||||||
|
|
||||||
/* PHY address */
|
|
||||||
unsigned long fault_offset =
|
|
||||||
(unsigned long)vmf->virtual_address - vma->vm_start + offset;
|
|
||||||
unsigned long fault_index = fault_offset>>PAGE_SHIFT;
|
|
||||||
int page_idx;
|
int page_idx;
|
||||||
|
|
||||||
if (vma == NULL)
|
if (vma == NULL)
|
||||||
return VM_FAULT_SIGBUS;
|
return VM_FAULT_SIGBUS;
|
||||||
|
|
||||||
|
offset = vma->vm_pgoff << PAGE_SHIFT;
|
||||||
|
|
||||||
|
/* PHY address */
|
||||||
|
fault_offset =
|
||||||
|
(unsigned long)vmf->virtual_address - vma->vm_start + offset;
|
||||||
|
fault_index = fault_offset>>PAGE_SHIFT;
|
||||||
|
|
||||||
pglist = vma->vm_private_data;
|
pglist = vma->vm_private_data;
|
||||||
|
|
||||||
page_idx = fault_index - pglist->index;
|
page_idx = fault_index - pglist->index;
|
||||||
|
@ -463,6 +464,7 @@ static int habmem_imp_hyp_map_fd(void *imp_ctx,
|
||||||
int i, j, k = 0;
|
int i, j, k = 0;
|
||||||
pgprot_t prot = PAGE_KERNEL;
|
pgprot_t prot = PAGE_KERNEL;
|
||||||
int32_t fd, size;
|
int32_t fd, size;
|
||||||
|
int ret;
|
||||||
DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
|
DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
|
||||||
|
|
||||||
if (!pfn_table || !priv)
|
if (!pfn_table || !priv)
|
||||||
|
@ -505,9 +507,10 @@ static int habmem_imp_hyp_map_fd(void *imp_ctx,
|
||||||
exp_info.priv = pglist;
|
exp_info.priv = pglist;
|
||||||
pglist->dmabuf = dma_buf_export(&exp_info);
|
pglist->dmabuf = dma_buf_export(&exp_info);
|
||||||
if (IS_ERR(pglist->dmabuf)) {
|
if (IS_ERR(pglist->dmabuf)) {
|
||||||
|
ret = PTR_ERR(pglist->dmabuf);
|
||||||
kfree(pages);
|
kfree(pages);
|
||||||
kfree(pglist);
|
kfree(pglist);
|
||||||
return PTR_ERR(pglist->dmabuf);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = dma_buf_fd(pglist->dmabuf, O_CLOEXEC);
|
fd = dma_buf_fd(pglist->dmabuf, O_CLOEXEC);
|
||||||
|
@ -579,8 +582,8 @@ static int habmem_imp_hyp_map_kva(void *imp_ctx,
|
||||||
pglist->kva = vmap(pglist->pages, pglist->npages, VM_MAP, prot);
|
pglist->kva = vmap(pglist->pages, pglist->npages, VM_MAP, prot);
|
||||||
if (pglist->kva == NULL) {
|
if (pglist->kva == NULL) {
|
||||||
kfree(pages);
|
kfree(pages);
|
||||||
kfree(pglist);
|
|
||||||
pr_err("%ld pages vmap failed\n", pglist->npages);
|
pr_err("%ld pages vmap failed\n", pglist->npages);
|
||||||
|
kfree(pglist);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,8 +124,7 @@ void habmem_remove_export(struct export_desc *exp)
|
||||||
struct uhab_context *ctx;
|
struct uhab_context *ctx;
|
||||||
|
|
||||||
if (!exp || !exp->ctx || !exp->pchan) {
|
if (!exp || !exp->ctx || !exp->pchan) {
|
||||||
pr_err("failed to find valid info in exp %pK ctx %pK pchan %pK\n",
|
pr_err("failed to find valid info in exp %pK\n", exp);
|
||||||
exp, exp->ctx, exp->pchan);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue