Skip to contentSkip to conversation

mtd: rawnand: atmel: use struct_size

PATCH Applied Rosen Penev 2 participants 2 messages Jun 30 – Jul 3

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

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.

---
 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
index e7fdf532c5fe..8a19408abb63 100644
@@ -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
maintainer Applied
#1 lore raw
Quoted 5 lines · Rosen Penev

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.

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