Free allocated memory before return because of NULL input

Signed-off-by: Xing Lin <[email protected]>
---
 src/osd/ErasureCodePluginJerasure/jerasure.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/osd/ErasureCodePluginJerasure/jerasure.c 
b/src/osd/ErasureCodePluginJerasure/jerasure.c
index 9efae02..1bb4b1d 100755
--- a/src/osd/ErasureCodePluginJerasure/jerasure.c
+++ b/src/osd/ErasureCodePluginJerasure/jerasure.c
@@ -276,7 +276,10 @@ int *jerasure_matrix_to_bitmatrix(int k, int m, int w, int 
*matrix)
   int rowelts, rowindex, colindex, elt, i, j, l, x;
 
   bitmatrix = talloc(int, k*m*w*w);
-  if (matrix == NULL) { return NULL; }
+  if (matrix == NULL) {
+    free(bitmatrix);
+    return NULL; 
+  }
 
   rowelts = k * w;
   rowindex = 0;
-- 
1.8.3.4 (Apple Git-47)

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to