mtd: rawnand: atmel: use struct_size
Subsystems (4)
PATCH 1/1 mtd: rawnand: atmel: use struct_size
The comment above makes it clear that this is a single element for legacy handling. Clarify that with struct_size and avoid manual pointer math.
Signed-off-by Rosen Penev <[email protected]>
--- drivers/mtd/nand/raw/atmel/nand-controller.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +1 -2
@@ -1799,8 +1799,7 @@ atmel_nand_controller_legacy_add_nands(struct atmel_nand_controller *nc)* Legacy bindings only allow connecting a single NAND with a unique CS * line to the controller. */ - nand =devm_kzalloc (nc->dev,sizeof (*nand) +sizeof (*nand->cs), -GFP_KERNEL ); + nand =devm_kzalloc (nc->dev,struct_size (nand, cs,1 ),GFP_KERNEL );if (!nand)return -ENOMEM ;
Signature · 1 line
2.54.0
Quoted 5 lines · Rosen Penev
The comment above makes it clear that this is a single element for legacy handling. Clarify that with
struct_sizeand avoid manual pointer math.
Applied to nand/next, thanks!
[1/1] mtd: rawnand: atmel: use struct_size
commit: 591b5ac17301acfbc8204dfa377353f2b20efc5b
Patche(s) should be available on mtd/linux.git and will be part of the next PR (provided that no robot complains by then).
Kind regards,
Miquèl