2021-03-08 08:42:00

by Jia-Ju Bai

[permalink] [raw]
Subject: [PATCH] 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 <[email protected]>
Signed-off-by: Jia-Ju Bai <[email protected]>
---
drivers/mtd/maps/physmap-core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c
index 001ed5deb622..4f63b8430c71 100644
--- a/drivers/mtd/maps/physmap-core.c
+++ b/drivers/mtd/maps/physmap-core.c
@@ -69,8 +69,10 @@ static int physmap_flash_remove(struct platform_device *dev)
int i, err = 0;

info = platform_get_drvdata(dev);
- if (!info)
+ if (!info) {
+ err = -EINVAL;
goto out;
+ }

if (info->cmtd) {
err = mtd_device_unregister(info->cmtd);
--
2.17.1


2021-03-11 11:40:43

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH] mtd: maps: fix error return code of physmap_flash_remove()

On Mon, 2021-03-08 at 03:44:46 UTC, Jia-Ju Bai wrote:
> 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 <[email protected]>
> Signed-off-by: Jia-Ju Bai <[email protected]>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel