Skip to contentSkip to conversation

s390/cpum_cf: Use kmalloc_array() in merge_attr()

PATCH In review SF Markus Elfring 2 participants 2 messages Sep 3, 2016 – Sep 5, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390/cpum_cf: Use kmalloc_array() in merge_attr()

From: Markus Elfring <[email protected]>
Date: Sat, 3 Sep 2016 15:17:45 +0200

* A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus reuse the corresponding function "kmalloc_array".

* 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.

---
 arch/s390/kernel/perf_cpum_cf_events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/perf_cpum_cf_events.c +1 -1
index 4554a4b..0d6340b 100644
@@ -274,7 +274,7 @@ static __init struct attribute **merge_attr(struct attribute **a,
 		j++;
 	j++;
 
-	new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL);
+	new = kmalloc_array(j, sizeof(*new), GFP_KERNEL);
 	if (!new)
 		return NULL;
 	j = 0;
Signature · 1 line
2.9.3
Acked-by on v1 1/1
#1 lore raw
Quoted 22 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 3 Sep 2016 15:17:45 +0200

* A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus reuse the corresponding function "kmalloc_array".

* 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.

---
 arch/s390/kernel/perf_cpum_cf_events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/perf_cpum_cf_events.c +0 -0
index 4554a4b..0d6340b 100644

arch/s390/kernel/perf_cpum_cf_events.c static __init struct attribute **merge_attr(struct attribute **a, · line 280

Quoted 8 lines
arch/s390/kernel/perf_cpum_cf_events.c +1 -1
@@ -274,7 +274,7 @@ static __init struct attribute **merge_attr(struct attribute **a,
 		j++;
 	j++;
 
-	new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL);
+	new = kmalloc_array(j, sizeof(*new), GFP_KERNEL);
 	if (!new)
 		return NULL;
 	j = 0;

Looks good to me. Thanks.