diff options
author | Georgiana Chelu <georgiana.chelu93@gmail.com> | 2017-09-26 09:01:29 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-09-29 15:34:37 +0200 |
commit | 63342e75e661c1b71a0f33a4329726bcf383b342 (patch) | |
tree | 00d66886796b97039cdc1871a37765a19a7d9d66 /drivers/staging | |
parent | 4d962df5a7771c90da738de0d24c3828fe23e060 (diff) |
Staging: media: atomisp: Use kmalloc_array instead of kmalloc
Prefer kmalloc_array over kmalloc with multiply
because kmalloc_array performs additional checks
before memory allocation.
Fix the following issue reported by checkpatch.pl:
* WARNING: Prefer kmalloc_array over kmalloc with multiply
Signed-off-by: Georgiana Chelu <georgiana.chelu93@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c index 11162f595fc7..5232327f5d9c 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c @@ -725,7 +725,7 @@ static int alloc_private_pages(struct hmm_buffer_object *bo, pgnr = bo->pgnr; - bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * pgnr, + bo->page_obj = kmalloc_array(pgnr, sizeof(struct hmm_page_object), GFP_KERNEL); if (unlikely(!bo->page_obj)) { dev_err(atomisp_dev, "out of memory for bo->page_obj\n"); @@ -990,13 +990,13 @@ static int alloc_user_pages(struct hmm_buffer_object *bo, struct vm_area_struct *vma; struct page **pages; - pages = kmalloc(sizeof(struct page *) * bo->pgnr, GFP_KERNEL); + pages = kmalloc_array(bo->pgnr, sizeof(struct page *), GFP_KERNEL); if (unlikely(!pages)) { dev_err(atomisp_dev, "out of memory for pages...\n"); return -ENOMEM; } - bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * bo->pgnr, + bo->page_obj = kmalloc_array(bo->pgnr, sizeof(struct hmm_page_object), GFP_KERNEL); if (unlikely(!bo->page_obj)) { dev_err(atomisp_dev, "out of memory for bo->page_obj...\n"); @@ -1363,7 +1363,7 @@ void *hmm_bo_vmap(struct hmm_buffer_object *bo, bool cached) bo->status &= ~(HMM_BO_VMAPED | HMM_BO_VMAPED_CACHED); } - pages = kmalloc(sizeof(*pages) * bo->pgnr, GFP_KERNEL); + pages = kmalloc_array(bo->pgnr, sizeof(*pages), GFP_KERNEL); if (unlikely(!pages)) { mutex_unlock(&bo->mutex); dev_err(atomisp_dev, "out of memory for pages...\n"); |