Commit e3139cef authored by Maurizio Lombardi's avatar Maurizio Lombardi Committed by Keith Busch
Browse files

nvme-core: fix a memory leak in nvme_ns_info_from_identify()



In case of error, free the nvme_id_ns structure that was allocated
by nvme_identify_ns().

Signed-off-by: default avatarMaurizio Lombardi <mlombard@redhat.com>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Reviewed-by: default avatarKanchan Joshi <joshi.k@samsung.com>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
parent 136cfcb8
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -1487,7 +1487,8 @@ static int nvme_ns_info_from_identify(struct nvme_ctrl *ctrl,
	if (id->ncap == 0) {
		/* namespace not allocated or attached */
		info->is_removed = true;
		return -ENODEV;
		ret = -ENODEV;
		goto error;
	}

	info->anagrpid = id->anagrpid;
@@ -1505,8 +1506,10 @@ static int nvme_ns_info_from_identify(struct nvme_ctrl *ctrl,
		    !memchr_inv(ids->nguid, 0, sizeof(ids->nguid)))
			memcpy(ids->nguid, id->nguid, sizeof(ids->nguid));
	}

error:
	kfree(id);
	return 0;
	return ret;
}

static int nvme_ns_info_from_id_cs_indep(struct nvme_ctrl *ctrl,