mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-08 14:13:53 +00:00
nvme-core: fix a memory leak in nvme_ns_info_from_identify()
[ Upstream commit e3139cef82
]
In case of error, free the nvme_id_ns structure that was allocated
by nvme_identify_ns().
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
a37096b079
commit
3c781fbb4f
@ -1511,7 +1511,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;
|
||||
@ -1529,8 +1530,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,
|
||||
|
Loading…
Reference in New Issue
Block a user