osd/erasurecode: Fix memory leak in jerasure_matrix_to_bitmatrix()
PATCH 1/1 osd/erasurecode: Fix memory leak in jerasure_matrix_to_bitmatrix()
Free allocated memory before return because of NULL input
--- src/osd/ErasureCodePluginJerasure/jerasure.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
src/osd/ErasureCodePluginJerasure/jerasure.c +4 -1
@@ -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 ;
Signature · 1 line
1.8.3.4 (Apple Git-47)
Hi!
Quoted 12 lines · Xing Lin
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(-)src/osd/ErasureCodePluginJerasure/jerasure.c +0
-0
src/osd/ErasureCodePluginJerasure/jerasure.c int *jerasure_matrix_to_bitmatrix(int k, int m, int w, int *matrix) · line 282
Quoted 8 lines
src/osd/ErasureCodePluginJerasure/jerasure.c +4
-1@@ -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 ; + }
I have a feeling the author meant to say if (bitmatrix == NULL), since all the other talloc calls in this file tend to be followed by a NULL check?
sage
Quoted 12 lines
src/osd/ErasureCodePluginJerasure/jerasure.c +0
-1rowelts = 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
Quoted 17 lines · Sage Weil
Hi!
Quoted 14 lines · Xing Lin
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(-)src/osd/ErasureCodePluginJerasure/jerasure.c +0
-0@@ -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;
Quoted 9 lines
src/osd/ErasureCodePluginJerasure/jerasure.c int *jerasure_matrix_to_bitmatrix(int k, int m, int w, int *matrix) · line 282
Quoted 6 lines
src/osd/ErasureCodePluginJerasure/jerasure.c +4
-1bitmatrix =talloc (int, k*m*w*w); -if (matrix ==NULL ) {return NULL ; } +if (matrix ==NULL ) { +free (bitmatrix); +return NULL ; + }I have a feeling the author meant to say if (bitmatrix == NULL), since all the other talloc calls in this file tend to be followed by a NULL check?
Yes. Good catch Xing Lin :-)
Cheers
Quoted 21 lines
sage
Quoted 6 lines
src/osd/ErasureCodePluginJerasure/jerasure.c +0
-1rowelts = k * w; rowindex =0 ; --1.8.3.4 (Apple Git-47)
Quoted 6 lines
--
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--
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
Signature · 1 line
Loïc Dachary, Artisan Logiciel Libre
Hi !
In this case, it should be more efficient to do the NULL check before the talloc (you'll save the free operation and a useless memory allocation)
Cheers,
Philippe
-----Message d'origine-----
De : [email protected] [mailto:[email protected]] De la part de Loic Dachary Envoyé : samedi 2 novembre 2013 10:17
À : Sage Weil; Xing Lin
Cc : [email protected]
Objet : Re: [PATCH] osd/erasurecode: Fix memory leak in jerasure_matrix_to_bitmatrix()
Quoted 18 lines · Sage Weil
Hi!
Quoted 15 lines · Xing Lin
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(-)src/osd/ErasureCodePluginJerasure/jerasure.c +0
-0@@ -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;
Quoted 9 lines
src/osd/ErasureCodePluginJerasure/jerasure.c int *jerasure_matrix_to_bitmatrix(int k, int m, int w, int *matrix) · line 282
Quoted 6 lines
src/osd/ErasureCodePluginJerasure/jerasure.c +4
-1bitmatrix =talloc (int, k*m*w*w); -if (matrix ==NULL ) {return NULL ; } +if (matrix ==NULL ) { +free (bitmatrix); +return NULL ; + }I have a feeling the author meant to say if (bitmatrix == NULL), since all the other talloc calls in this file tend to be followed by a NULL check?
Yes. Good catch Xing Lin :-)
Cheers
Quoted 16 lines
sage
Quoted 6 lines
src/osd/ErasureCodePluginJerasure/jerasure.c +0
-1rowelts = k * w; rowindex =0 ; --1.8.3.4 (Apple Git-47)
Quoted 6 lines
--
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
Quoted 5 lines
--
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
--
Loïc Dachary, Artisan Logiciel Libre
--
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
Quoted 4 lines · On 04/11/2013 18:44, [email protected] wrote:
Hi !
In this case, it should be more efficient to do the NULL check before the talloc (you'll save the free operation and a useless memory allocation)
Hi,
The check is on bitmatrix actually ;-)
Cheers
Quoted 76 lines
Cheers,
Philippe-----Message d'origine-----
De : [email protected] [mailto:[email protected]] De la part de Loic Dachary Envoyé : samedi 2 novembre 2013 10:17
À : Sage Weil; Xing Lin
Cc : [email protected]
Objet : Re: [PATCH] osd/erasurecode: Fix memory leak injerasure_matrix_to_bitmatrix()Quoted 18 lines · Sage Weil
Hi!
Quoted 15 lines · Xing Lin
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(-)src/osd/ErasureCodePluginJerasure/jerasure.c +0
-0@@ -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;Quoted 9 lines
src/osd/ErasureCodePluginJerasure/jerasure.c int *jerasure_matrix_to_bitmatrix(int k, int m, int w, int *matrix) · line 282
Quoted 6 lines
src/osd/ErasureCodePluginJerasure/jerasure.c +4
-1bitmatrix =talloc (int, k*m*w*w); -if (matrix ==NULL ) {return NULL ; } +if (matrix ==NULL ) { +free (bitmatrix); +return NULL ; + }I have a feeling the author meant to say if (bitmatrix == NULL), since all the other talloc calls in this file tend to be followed by a NULL check?
Yes. Good catch Xing Lin :-)
Cheers
Quoted 16 lines
sage
Quoted 6 lines
src/osd/ErasureCodePluginJerasure/jerasure.c +0
-1rowelts = k * w; rowindex =0 ; --1.8.3.4 (Apple Git-47)
Quoted 6 lines
--
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.htmlQuoted 5 lines
--
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--
Loïc Dachary, Artisan Logiciel Libre--
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
Signature · 1 line
Loïc Dachary, Artisan Logiciel Libre