* [PATCH] md/dm-stats: Use kmalloc_array() in parse_histogram()
@ 2016-10-01 4:06 SF Markus Elfring
0 siblings, 0 replies; only message in thread
From: SF Markus Elfring @ 2016-10-01 4:06 UTC (permalink / raw)
To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 05:55:05 +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.
* Replace the specification of a data type by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/dm-stats.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
index 38b05f2..7b79425 100644
--- a/drivers/md/dm-stats.c
+++ b/drivers/md/dm-stats.c
@@ -917,7 +917,9 @@ static int parse_histogram(const char *h, unsigned *n_histogram_entries,
if (*q == ',')
(*n_histogram_entries)++;
- *histogram_boundaries = kmalloc(*n_histogram_entries * sizeof(unsigned long long), GFP_KERNEL);
+ *histogram_boundaries = kmalloc_array(*n_histogram_entries,
+ sizeof(**histogram_boundaries),
+ GFP_KERNEL);
if (!*histogram_boundaries)
return -ENOMEM;
--
2.10.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-10-01 4:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-01 4:06 [PATCH] md/dm-stats: Use kmalloc_array() in parse_histogram() SF Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox