Skip to content

Commit 34684bb

Browse files
ethancedwards8miquelraynal
authored andcommitted
mtd: rawnand: use kcalloc() instead of kzalloc()
We are trying to get rid of all multiplications from allocation functions to prevent integer overflows[1]. Here the multiplication is obviously safe, but using kcalloc() is more appropriate and improves readability. This patch has no effect on runtime behavior. Link: KSPP#162 [1] Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments Signed-off-by: Ethan Carter Edwards <[email protected]> Signed-off-by: Miquel Raynal <[email protected]>
1 parent 1db50b9 commit 34684bb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/mtd/nand/raw/nand_base.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@ int nand_readid_op(struct nand_chip *chip, u8 addr, void *buf,
18331833

18341834
/* READ_ID data bytes are received twice in NV-DDR mode */
18351835
if (len && nand_interface_is_nvddr(conf)) {
1836-
ddrbuf = kzalloc(len * 2, GFP_KERNEL);
1836+
ddrbuf = kcalloc(2, len, GFP_KERNEL);
18371837
if (!ddrbuf)
18381838
return -ENOMEM;
18391839

@@ -2203,7 +2203,7 @@ int nand_read_data_op(struct nand_chip *chip, void *buf, unsigned int len,
22032203
* twice.
22042204
*/
22052205
if (force_8bit && nand_interface_is_nvddr(conf)) {
2206-
ddrbuf = kzalloc(len * 2, GFP_KERNEL);
2206+
ddrbuf = kcalloc(2, len, GFP_KERNEL);
22072207
if (!ddrbuf)
22082208
return -ENOMEM;
22092209

0 commit comments

Comments
 (0)