Skip to content

Commit

Permalink
net: lib: nrf_cloud: Set job type to invalid after job info is freed.
Browse files Browse the repository at this point in the history
Fixes a bug that prevents a new MQTT FOTA job from being started after
a FOTA job has just completed.
IRIS-6799

Signed-off-by: Justin Morton <justin.morton@nordicsemi.no>
  • Loading branch information
jayteemo authored and nordicjm committed Aug 11, 2023
1 parent a0209cc commit 0f55e16
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ Libraries for networking
* Moved JSON manipulation from :file:`nrf_cloud_fota.c` to :file:`nrf_cloud_codec_internal.c`.
* Fixed a build issue that occurred when MQTT and P-GPS are enabled and A-GPS is disabled.
* :c:func:`nrf_cloud_obj_location_request_create` to use the new function :c:func:`nrf_cloud_obj_location_request_payload_add`.
* Fixed a bug that prevented an MQTT FOTA job from being started.

* Removed:

Expand Down
2 changes: 1 addition & 1 deletion include/net/nrf_cloud_coap.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ int nrf_cloud_coap_location_get(struct nrf_cloud_rest_location_request const *co
*
* @param[out] job Parsed job info. If no job exists, type will
* be set to invalid. If a job exists, user must call
* @ref nrf_cloud_rest_fota_job_free to free the memory
* @ref nrf_cloud_coap_fota_job_free to free the memory
* allocated by this function.
*
* @return 0 if the request succeeded, a positive value indicating a CoAP result code,
Expand Down
11 changes: 4 additions & 7 deletions subsys/net/lib/nrf_cloud/src/nrf_cloud_codec_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1794,13 +1794,12 @@ void nrf_cloud_fota_job_free(struct nrf_cloud_fota_job_info *const job)
}

nrf_cloud_free(job->id);
job->id = NULL;

nrf_cloud_free(job->host);
job->host = NULL;

nrf_cloud_free(job->path);
job->path = NULL;

/* Reset entire struct since info is no longer valid */
memset(job, 0, sizeof(*job));
job->type = NRF_CLOUD_FOTA_TYPE__INVALID;
}

/* FOTA job format via MQTT:
Expand Down Expand Up @@ -2254,8 +2253,6 @@ int nrf_cloud_rest_fota_execution_decode(const char *const response,
}

nrf_cloud_fota_job_free(job);
memset(job, 0, sizeof(*job));
job->type = NRF_CLOUD_FOTA_TYPE__INVALID;

return ret;
}
Expand Down

0 comments on commit 0f55e16

Please sign in to comment.