Skip to content

Commit 19259ab

Browse files
de-nordicmbolivar-nordic
authored andcommitted
mgmt/mcumgr/lib: Fix image list command crashing when no device
It is possible, in case of two application images, to have no access to one of devices of the secondary image. When asserts are enabled, such situation causes crash even though the image list command can handle it with no problem. The commit removes the assert and adds additional swap type: IMG_MGMT_SWAP_TYPE_UNKNOWN to indicate situations where it was not possible to obtain swap type from boot_util. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 54b2fc0 commit 19259ab

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

subsys/mgmt/mcumgr/lib/cmd/img_mgmt/include/img_mgmt/img_mgmt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ extern "C" {
4141
#define IMG_MGMT_SWAP_TYPE_TEST 1
4242
#define IMG_MGMT_SWAP_TYPE_PERM 2
4343
#define IMG_MGMT_SWAP_TYPE_REVERT 3
44+
#define IMG_MGMT_SWAP_TYPE_UNKNOWN 255
4445

4546
/**
4647
* Command IDs for image management group.

subsys/mgmt/mcumgr/lib/cmd/img_mgmt/src/zephyr_img_mgmt.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,7 @@ img_mgmt_impl_swap_type(int slot)
511511
case BOOT_SWAP_TYPE_REVERT:
512512
return IMG_MGMT_SWAP_TYPE_REVERT;
513513
default:
514-
assert(0);
515-
return IMG_MGMT_SWAP_TYPE_NONE;
514+
return IMG_MGMT_SWAP_TYPE_UNKNOWN;
516515
}
517516
}
518517

0 commit comments

Comments
 (0)