apache / mynewt-mcumgr

Apache mynewt
https://mynewt.apache.org/
99 stars 76 forks source link

image erase: allow only when slot image is not backup/pending... #11

Closed nvlsianpu closed 6 years ago

nvlsianpu commented 6 years ago

It was possible to erase slot 1 while it stores confirmed image while ongoing test run - this is unwanted behavior which allow to even brick remote device accidentally. This patch add check for such case of test run etc. This also aligns condition required for erase command execution to similar as upload command requires.

Signed-off-by: Andrzej Puzdrowski andrzej.puzdrowski@nordicsemi.no

nvlsianpu commented 6 years ago

Can you look at this @ccollins476ad @carlescufi

utzig commented 6 years ago

I think you should be returning MGMT_ERR_EBADSTATE instead of MGMT_ERR_ENOMEM.

nvlsianpu commented 6 years ago

Changed. I think here: https://github.com/apache/mynewt-mcumgr/pull/11/files#diff-265d4384c83b545f6d7e6837596331bcR295 the same error-code should be used. What do you think?

utzig commented 6 years ago

I think the second one actually makes a little sense semantically, because if there is no available slot it could be "no mem", but erasing "no mem" would be weirder, so makes more sense to say it cannot erase because of a bad state.

nvlsianpu commented 6 years ago

@utzig merge?