Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mtd: virt_concat: use single allocation for node

Simpler to reason about and avoids having to free nodes separately.

Also add __counted_by attribute for extra runtime analysis.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

authored by

Rosen Penev and committed by
Miquel Raynal
c685e6e8 87d8f128

+2 -9
+2 -9
drivers/mtd/mtd_virt_concat.c
··· 31 31 struct mtd_virt_concat_node { 32 32 struct list_head head; 33 33 unsigned int count; 34 - struct device_node **nodes; 35 34 struct mtd_concat *concat; 35 + struct device_node *nodes[] __counted_by(count); 36 36 }; 37 37 38 38 /** ··· 133 133 for (idx = 0; idx < item->count; idx++) 134 134 of_node_put(item->nodes[idx]); 135 135 136 - kfree(item->nodes); 137 136 kfree(item); 138 137 } 139 138 return 0; ··· 166 167 return 0; 167 168 } 168 169 169 - item = kzalloc(sizeof(*item), GFP_KERNEL); 170 + item = kzalloc_flex(*item, nodes, count, GFP_KERNEL); 170 171 if (!item) 171 172 return -ENOMEM; 172 173 173 174 item->count = count; 174 - item->nodes = kcalloc(count, sizeof(*item->nodes), GFP_KERNEL); 175 - if (!item->nodes) { 176 - kfree(item); 177 - return -ENOMEM; 178 - } 179 175 180 176 /* 181 177 * The partition in which "part-concat-next" property ··· 210 216 for (i = 0; i < item->count; i++) 211 217 of_node_put(item->nodes[i]); 212 218 213 - kfree(item->nodes); 214 219 kfree(item); 215 220 } 216 221 }