Skip to contentSkip to conversation

fs/squashfs/file_direct.c: replace count*size kmalloc by kcalloc

PATCH Superseded Fabian Frederick 2 participants 2 messages Jun 16, 2014 SquashFS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/squashfs/file_direct.c: replace count*size kmalloc by kcalloc

kcalloc manages count*sizeof overflow.

Cc Phillip Lougher <[email protected]>
Cc Andrew Morton <[email protected]>
---
 fs/squashfs/file_direct.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/squashfs/file_direct.c +1 -1
index 62a0de6..e9f9cf2 100644
@@ -44,7 +44,7 @@ int squashfs_readpage_block(struct page *target_page, u64 block, int bsize)
 
 	pages = end_index - start_index + 1;
 
-	page = kmalloc(sizeof(void *) * pages, GFP_KERNEL);
+	page = kcalloc(pages, sizeof(void *), GFP_KERNEL);
 	if (page == NULL)
 		return res;
 
Signature · 1 line
1.8.4.5
#1 lore raw
Quoted 1 line · Fabian Frederick

kcalloc manages count*sizeof overflow.

so does kmalloc_array

fs/squashfs/file_direct.c

Quoted 1 line
fs/squashfs/file_direct.c +0 -0

[]

fs/squashfs/file_direct.c int squashfs_readpage_block(struct page *target_page, u64 block, int bsize) · line 47

Quoted 2 lines
fs/squashfs/file_direct.c +1 -1
-	page = kmalloc(sizeof(void *) * pages, GFP_KERNEL);
+	page = kcalloc(pages, sizeof(void *), GFP_KERNEL);

kmalloc(a * sizeof(b), GFP) -> kmalloc_array(a, sizeof(b), GFP) kzalloc(a * sizeof(b), GFP) -> kcalloc(a, sizeof(b), GFP)