diff mbox series

[v2,2/3] part: Fix bogus return from part_get_info_by_dev_and_name

Message ID 20210412225307.3217317-2-sean.anderson@seco.com
State Accepted
Commit fe5a50910a64d8773fcd1454631d28da72319f28
Delegated to: Tom Rini
Headers show
Series [v2,1/3] cmd: fs: Use part_get_info_by_dev_and_name_or_num to parse partitions | expand

Commit Message

Sean Anderson April 12, 2021, 10:53 p.m. UTC
blk_get_device_by_str returns the device number on success. So we must
check if the return was negative to determine an error.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

Changes in v2:
- New

 disk/part.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Glass April 14, 2021, 7:37 p.m. UTC | #1
On Mon, 12 Apr 2021 at 23:53, Sean Anderson <sean.anderson@seco.com> wrote:
>
> blk_get_device_by_str returns the device number on success. So we must
> check if the return was negative to determine an error.
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
>
> Changes in v2:
> - New
>
>  disk/part.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini April 23, 2021, 4:24 p.m. UTC | #2
On Mon, Apr 12, 2021 at 06:53:06PM -0400, Sean Anderson wrote:

> blk_get_device_by_str returns the device number on success. So we must
> check if the return was negative to determine an error.
> 
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/disk/part.c b/disk/part.c
index 80ced2ba88..5e7e59cf25 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -725,7 +725,7 @@  static int part_get_info_by_dev_and_name(const char *dev_iface,
 	}
 
 	ret = blk_get_device_by_str(dev_iface, dev_str, dev_desc);
-	if (ret)
+	if (ret < 0)
 		goto cleanup;
 
 	ret = part_get_info_by_name(*dev_desc, part_str, part_info);