Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1486632
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/5] GPU-DRM: Use kmalloc_array() in drm_legacy_addbufs_pci() |
| Date | 2016-09-19 18:00 +0200 |
| Message-ID | <sj998-7ii-31@gated-at.bofh.it> (permalink) |
| References | <qEuGl-43C-5@gated-at.bofh.it> <sj998-7ii-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 19 Sep 2016 17:07:06 +0200
A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/gpu/drm/drm_bufs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 3219151..ed33f43 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -923,8 +923,9 @@ int drm_legacy_addbufs_pci(struct drm_device *dev,
/* Keep the original pagelist until we know all the allocations
* have succeeded
*/
- temp_pagelist = kmalloc((dma->page_count + (count << page_order)) *
- sizeof(*dma->pagelist), GFP_KERNEL);
+ temp_pagelist = kmalloc_array(dma->page_count + (count << page_order),
+ sizeof(*dma->pagelist),
+ GFP_KERNEL);
if (!temp_pagelist) {
kfree(entry->buflist);
kfree(entry->seglist);
--
2.10.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/5] GPU-DRM: Fine-tuning for four function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-19 18:00 +0200
[PATCH 4/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-19 18:00 +0200
Re: [PATCH 4/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg() Daniel Vetter <daniel@ffwll.ch> - 2016-09-21 13:30 +0200
[PATCH 3/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_agp() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-19 18:00 +0200
[PATCH 1/5] GPU-DRM: Use kmalloc_array() in drm_legacy_addbufs_pci() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-19 18:00 +0200
[PATCH 2/5] GPU-DRM: Replace two kzalloc() calls by kcalloc() in drm_legacy_addbufs_pci() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-19 18:00 +0200
csiph-web