Skip to content

Commit caa0ecb

Browse files
Xu Raomiquelraynal
authored andcommitted
mtd: virt-concat: free duplicate generated name
Every MTD registration runs mtd_virt_concat_create_join(). Once a virtual concat has already been registered, the function builds the same name again and takes the equal-name branch. That branch skips to the next item without freeing the newly allocated string. Free the temporary name before continuing. Fixes: 43db636 ("mtd: Add driver for concatenating devices") Cc: stable@vger.kernel.org Signed-off-by: Xu Rao <raoxu@uniontech.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
1 parent 16f7ec8 commit caa0ecb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/mtd/mtd_virt_concat.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,10 @@ int mtd_virt_concat_create_join(void)
321321

322322
if (concat->mtd.name) {
323323
ret = memcmp(concat->mtd.name, name, name_sz);
324-
if (ret == 0)
324+
if (ret == 0) {
325+
kfree(name);
325326
continue;
327+
}
326328
}
327329
mtd = mtd_concat_create(concat->subdev, concat->num_subdev, name);
328330
if (!mtd) {

0 commit comments

Comments
 (0)