]> Pileus Git - ~andy/linux/commitdiff
ceph: improve error handling in ceph_mdsmap_decode
authorEmil Goode <emilgoode@gmail.com>
Tue, 28 May 2013 14:59:00 +0000 (16:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jan 2014 20:24:24 +0000 (12:24 -0800)
commit c213b50b7dcbf06abcfbf1e4eee5b76586718bd9 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ceph/mdsmap.c

index 9278dec9e9400aa222c6e73fcaa144405644c056..d4d38977dcbb0bf8e4cdaf2c0534f8a71c27c2c8 100644 (file)
@@ -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)