[PATCH v7 01/26] spl: blk_fs: Fix uninitialized return value when we can't get a blk_desc

Sean Anderson seanga2 at gmail.com
Wed Nov 8 17:48:33 CET 2023


Initialize ret to avoid returning garbage if blk_get_devnum_by_uclass_id
fails.

Fixes: 8ce6a2e1757 ("spl: blk: Support loading images from fs")
Signed-off-by: Sean Anderson <seanga2 at gmail.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
---

(no changes since v6)

Changes in v6:
- New

 common/spl/spl_blk_fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/spl/spl_blk_fs.c b/common/spl/spl_blk_fs.c
index 63825d620d1..144c8a65b5d 100644
--- a/common/spl/spl_blk_fs.c
+++ b/common/spl/spl_blk_fs.c
@@ -50,7 +50,7 @@ int spl_blk_load_image(struct spl_image_info *spl_image,
 	struct blk_desc *blk_desc;
 	loff_t actlen, filesize;
 	struct blk_dev dev;
-	int ret;
+	int ret = -ENODEV;
 
 	blk_desc = blk_get_devnum_by_uclass_id(uclass_id, devnum);
 	if (!blk_desc) {
-- 
2.37.1



More information about the U-Boot mailing list