diff options
author | Emil Goode <emilgoode@gmail.com> | 2013-05-28 16:59:00 +0200 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-07-01 09:52:02 -0700 |
commit | c213b50b7dcbf06abcfbf1e4eee5b76586718bd9 (patch) | |
tree | 66a2ae00a8e9e6e619d4722b5c2a0e53380765fd /fs/ceph/mdsmap.c | |
parent | 912c317d4600b81664ad8f3d3ba6c1f2ff4b49c2 (diff) | |
download | blackbird-obmc-linux-c213b50b7dcbf06abcfbf1e4eee5b76586718bd9.tar.gz blackbird-obmc-linux-c213b50b7dcbf06abcfbf1e4eee5b76586718bd9.zip |
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: Emil Goode <emilgoode@gmail.com>
Signed-off-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'fs/ceph/mdsmap.c')
-rw-r--r-- | fs/ceph/mdsmap.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/ceph/mdsmap.c b/fs/ceph/mdsmap.c index 9278dec9e940..d4d38977dcbb 100644 --- a/fs/ceph/mdsmap.c +++ b/fs/ceph/mdsmap.c @@ -138,6 +138,8 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end) m->m_info[mds].export_targets = kcalloc(num_export_targets, sizeof(u32), GFP_NOFS); + if (m->m_info[mds].export_targets == NULL) + goto badmem; for (j = 0; j < num_export_targets; j++) m->m_info[mds].export_targets[j] = ceph_decode_32(&pexport_targets); @@ -170,7 +172,7 @@ bad: DUMP_PREFIX_OFFSET, 16, 1, start, end - start, true); ceph_mdsmap_destroy(m); - return ERR_PTR(-EINVAL); + return ERR_PTR(err); } void ceph_mdsmap_destroy(struct ceph_mdsmap *m) |