forked from Minki/linux
ceph: fix possible null-pointer dereference in ceph_mdsmap_decode()
kcalloc() is called to allocate memory for m->m_info, and if it fails, ceph_mdsmap_destroy() behind the label out_err will be called: ceph_mdsmap_destroy(m); In ceph_mdsmap_destroy(), m->m_info is dereferenced through: kfree(m->m_info[i].export_targets); To fix this possible null-pointer dereference, check m->m_info before the for loop to free m->m_info[i].export_targets. [ jlayton: fix up whitespace damage only kfree(m->m_info) if it's non-NULL ] Reported-by: TOTE Robot <oslab@tsinghua.edu.cn> Signed-off-by: Tuo Li <islituo@gmail.com> Signed-off-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
parent
b2f9fa1f3b
commit
a9e6ffbc5b
@ -394,9 +394,11 @@ void ceph_mdsmap_destroy(struct ceph_mdsmap *m)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < m->possible_max_rank; i++)
|
if (m->m_info) {
|
||||||
kfree(m->m_info[i].export_targets);
|
for (i = 0; i < m->possible_max_rank; i++)
|
||||||
kfree(m->m_info);
|
kfree(m->m_info[i].export_targets);
|
||||||
|
kfree(m->m_info);
|
||||||
|
}
|
||||||
kfree(m->m_data_pg_pools);
|
kfree(m->m_data_pg_pools);
|
||||||
kfree(m);
|
kfree(m);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user