Skip to content

Commit 98f2233

Browse files
Erick Archervinodkoul
authored andcommitted
dmaengine: pl08x: Use kcalloc() instead of kzalloc()
This is an effort to get rid of all multiplications from allocation functions in order to prevent integer overflows [1]. Here the multiplication is obviously safe because the "channels" member can only be 8 or 2. This value is set when the "vendor_data" structs are initialized. static struct vendor_data vendor_pl080 = { [...] .channels = 8, [...] }; static struct vendor_data vendor_nomadik = { [...] .channels = 8, [...] }; static struct vendor_data vendor_pl080s = { [...] .channels = 8, [...] }; static struct vendor_data vendor_pl081 = { [...] .channels = 2, [...] }; However, using kcalloc() is more appropriate [1] 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 [1] Reviewed-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Erick Archer <[email protected]> Link: https://lore.kernel.org/r/AS8PR02MB72373D9261B3B166048A8E218B392@AS8PR02MB7237.eurprd02.prod.outlook.com Signed-off-by: Vinod Koul <[email protected]>
1 parent bd2f66b commit 98f2233

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/dma/amba-pl08x.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,8 +2855,8 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)
28552855
}
28562856

28572857
/* Initialize physical channels */
2858-
pl08x->phy_chans = kzalloc((vd->channels * sizeof(*pl08x->phy_chans)),
2859-
GFP_KERNEL);
2858+
pl08x->phy_chans = kcalloc(vd->channels, sizeof(*pl08x->phy_chans),
2859+
GFP_KERNEL);
28602860
if (!pl08x->phy_chans) {
28612861
ret = -ENOMEM;
28622862
goto out_no_phychans;

0 commit comments

Comments
 (0)