]> git.baikalelectronics.ru Git - kernel.git/commit
ceph: fix possible null-pointer dereference in ceph_mdsmap_decode()
authorTuo Li <islituo@gmail.com>
Thu, 5 Aug 2021 15:14:34 +0000 (08:14 -0700)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 25 Aug 2021 14:34:11 +0000 (16:34 +0200)
commit9d038f4374188c8040492a3369736a7f1aa474f8
tree7695955e3594802e4e38af6906ab468db92f07f2
parent816dafc829e1f5699ea09e1a7c922abf0f197d31
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>
fs/ceph/mdsmap.c