lkml.org 
[lkml]   [2016]   [Dec]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 01/19] [media] uvc_driver: Use kmalloc_array() in uvc_simplify_fraction()
From
Date
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 24 Dec 2016 21:10:16 +0100

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/media/usb/uvc/uvc_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 04bf35063c4c..a64b5029f262 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -253,7 +253,7 @@ void uvc_simplify_fraction(uint32_t *numerator, uint32_t *denominator,
uint32_t x, y, r;
unsigned int i, n;

- an = kmalloc(n_terms * sizeof *an, GFP_KERNEL);
+ an = kmalloc_array(n_terms, sizeof(*an), GFP_KERNEL);
if (an == NULL)
return;

--
2.11.0
\
 
 \ /
  Last update: 2016-12-25 19:30    [W:0.076 / U:1.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site