提交 c213b50b 编写于 作者: E Emil Goode 提交者: Sage Weil

ceph: improve error handling in ceph_mdsmap_decode

This patch makes the following improvements to the error handling
in the ceph_mdsmap_decode function:

- Add a NULL check for return value from kcalloc
- Make use of the variable err
Signed-off-by: NEmil Goode <emilgoode@gmail.com>
Signed-off-by: NSage Weil <sage@inktank.com>
上级 912c317d
...@@ -138,6 +138,8 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end) ...@@ -138,6 +138,8 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end)
m->m_info[mds].export_targets = m->m_info[mds].export_targets =
kcalloc(num_export_targets, sizeof(u32), kcalloc(num_export_targets, sizeof(u32),
GFP_NOFS); GFP_NOFS);
if (m->m_info[mds].export_targets == NULL)
goto badmem;
for (j = 0; j < num_export_targets; j++) for (j = 0; j < num_export_targets; j++)
m->m_info[mds].export_targets[j] = m->m_info[mds].export_targets[j] =
ceph_decode_32(&pexport_targets); ceph_decode_32(&pexport_targets);
...@@ -170,7 +172,7 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end) ...@@ -170,7 +172,7 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end)
DUMP_PREFIX_OFFSET, 16, 1, DUMP_PREFIX_OFFSET, 16, 1,
start, end - start, true); start, end - start, true);
ceph_mdsmap_destroy(m); ceph_mdsmap_destroy(m);
return ERR_PTR(-EINVAL); return ERR_PTR(err);
} }
void ceph_mdsmap_destroy(struct ceph_mdsmap *m) void ceph_mdsmap_destroy(struct ceph_mdsmap *m)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册