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

mtd: maps: fix error return code of physmap_flash_remove()

When platform_get_drvdata() returns NULL to info, no error return code
of physmap_flash_remove() is assigned.
To fix this bug, err is assigned with -EINVAL in this case

Fixes: 73566edf9b91 ("[MTD] Convert physmap to platform driver")
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210308034446.3052-1-baijiaju1990@gmail.com

authored by

Jia-Ju Bai and committed by
Miquel Raynal
620b90d3 b87b6d2d

+3 -1
+3 -1
drivers/mtd/maps/physmap-core.c
··· 69 69 int i, err = 0; 70 70 71 71 info = platform_get_drvdata(dev); 72 - if (!info) 72 + if (!info) { 73 + err = -EINVAL; 73 74 goto out; 75 + } 74 76 75 77 if (info->cmtd) { 76 78 err = mtd_device_unregister(info->cmtd);