diff options
| author | Chance Yang <[email protected]> | 2025-08-26 11:36:17 +0800 |
|---|---|---|
| committer | Mattijs Korpershoek <[email protected]> | 2025-09-30 11:48:51 +0200 |
| commit | 3ce8a0e9115eaa0cdfc142459814b2283cf01785 (patch) | |
| tree | f1ef5cc32af2d20fccd1ffa30d364b3015d57914 /drivers/fastboot | |
| parent | 9710d98e8942151fc0c62d54100d9d27e8263d04 (diff) | |
fastboot: Fix has-slot command always returning yes for fb_nand
The issue was a mismatch in return value conventions between functions:
- getvar_get_part_info() expects >= 0 for success
- fb_nand_lookup() returns 0 on success, 1 on failure (from
mtdparts_init and find_dev_and_part)
When partition didn't exist, fb_nand_lookup returned 1, but
fastboot_nand_get_part_info passed it directly to getvar_get_part_info,
which treated 1 >= 0 as success, causing has-slot to always return yes.
Fix by converting positive return values to -ENOENT in
fastboot_nand_get_part_info to match the expected error convention.
Signed-off-by: Chance Yang <[email protected]>
Reviewed-by: Mattijs Korpershoek <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mattijs Korpershoek <[email protected]>
Diffstat (limited to 'drivers/fastboot')
| -rw-r--r-- | drivers/fastboot/fb_nand.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/fastboot/fb_nand.c b/drivers/fastboot/fb_nand.c index afc64fd5280..6df3917e129 100644 --- a/drivers/fastboot/fb_nand.c +++ b/drivers/fastboot/fb_nand.c @@ -157,8 +157,13 @@ int fastboot_nand_get_part_info(const char *part_name, struct part_info **part_info, char *response) { struct mtd_info *mtd = NULL; + int ret; + + ret = fb_nand_lookup(part_name, &mtd, part_info, response); + if (ret) + return -ENOENT; - return fb_nand_lookup(part_name, &mtd, part_info, response); + return ret; } /** |
