bdev/nvme: Fix use after free in apply firmware RPC

Change-Id: I7ffe73e803ef416ce698df2d8403e32fa94ebccd
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/406988
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Ben Walker 2018-04-09 09:49:26 -07:00
parent 83b9f6864c
commit a28294b0b4

View File

@ -193,7 +193,7 @@ struct firmware_update_info {
static void
apply_firmware_cleanup(void *cb_arg)
{
struct open_descriptors *opt;
struct open_descriptors *opt, *tmp;
struct firmware_update_info *firm_ctx = cb_arg;
if (!firm_ctx) {
@ -208,7 +208,8 @@ apply_firmware_cleanup(void *cb_arg)
free_rpc_apply_firmware(firm_ctx->req);
free(firm_ctx->req);
}
TAILQ_FOREACH(opt, &firm_ctx->desc_head, tqlst) {
TAILQ_FOREACH_SAFE(opt, &firm_ctx->desc_head, tqlst, tmp) {
TAILQ_REMOVE(&firm_ctx->desc_head, opt, tqlst);
spdk_bdev_close(opt->desc);
free(opt);
}