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>
This commit is contained in:
parent
4d962df5a7
commit
63342e75e6
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue