diff --git a/target_if/spectral/target_if_spectral.c b/target_if/spectral/target_if_spectral.c index 3c8fed588b47..97124d070ab4 100644 --- a/target_if/spectral/target_if_spectral.c +++ b/target_if/spectral/target_if_spectral.c @@ -1011,6 +1011,23 @@ target_if_sops_stop_spectral_scan(void *arg) struct target_if_spectral *spectral = (struct target_if_spectral *)arg; uint8_t val = 0; int tempret, ret = 0; + uint8_t enabled = 0; + + tempret = target_if_spectral_info_read( + spectral, + TARGET_IF_SPECTRAL_INFO_ENABLED, + &enabled, sizeof(enabled)); + + if (tempret) + /* + * Could not determine if Spectral is enabled. Assume scan is + * not in progress + */ + enabled = 0; + + /* if scan is not enabled, no need to send stop to FW */ + if (!enabled) + return -EPERM; tempret = target_if_spectral_info_write( spectral,