diff --git a/src/fw_images.c b/src/fw_images.c index d2d1bb2..d78f91a 100644 --- a/src/fw_images.c +++ b/src/fw_images.c @@ -280,6 +280,15 @@ static int bbf_fw_image_download(struct ubus_context *ctx, struct fw_download_da char fault_msg[128] = {0}; time_t complete_time = 0; time_t start_time = time(NULL); + char *active_bank_id = NULL; + + // Check if trying to download in active bank + active_bank_id = get_fwbank_bank_id("active"); + if (DM_STRCMP(dw_data->bank_id, active_bank_id) == 0 ) { + res = -1; + snprintf(fault_msg, sizeof(fault_msg), "Trying to download in active bank %s", active_bank_id); + goto end; + } DM_STRNCPY(fw_image_path, "/tmp/firmware-XXXXXX", sizeof(fw_image_path)); @@ -661,8 +670,7 @@ static int operate_DeviceInfoFirmwareImage_Download(char *refparam, struct dmctx dw_data.obj_path = dmstrdup(obj_path); int res = bbf_fw_image_download(ctx->ubus_ctx, &dw_data); - - if (res == 1) { + if (res != 0) { bbfdm_set_fault_message(ctx, "Firmware validation failed"); }