* [PATCH] osd/erasurecode: Fix memory leak in jerasure_matrix_to_bitmatrix()
@ 2013-11-02 6:58 Xing Lin
2013-11-02 7:03 ` Sage Weil
0 siblings, 1 reply; 5+ messages in thread
From: Xing Lin @ 2013-11-02 6:58 UTC (permalink / raw)
To: ceph-devel; +Cc: sage, xinglin
Free allocated memory before return because of NULL input
Signed-off-by: Xing Lin <xinglin@cs.utah.edu>
---
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)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] osd/erasurecode: Fix memory leak in jerasure_matrix_to_bitmatrix()
2013-11-02 6:58 [PATCH] osd/erasurecode: Fix memory leak in jerasure_matrix_to_bitmatrix() Xing Lin
@ 2013-11-02 7:03 ` Sage Weil
2013-11-02 9:16 ` Loic Dachary
0 siblings, 1 reply; 5+ messages in thread
From: Sage Weil @ 2013-11-02 7:03 UTC (permalink / raw)
To: Xing Lin; +Cc: ceph-devel
Hi!
On Sat, 2 Nov 2013, Xing Lin wrote:
> Free allocated memory before return because of NULL input
>
> Signed-off-by: Xing Lin <xinglin@cs.utah.edu>
> ---
> 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;
> + }
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
>
> 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 majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] osd/erasurecode: Fix memory leak in jerasure_matrix_to_bitmatrix()
2013-11-02 7:03 ` Sage Weil
@ 2013-11-02 9:16 ` Loic Dachary
2013-11-04 10:44 ` philippe.raipin
0 siblings, 1 reply; 5+ messages in thread
From: Loic Dachary @ 2013-11-02 9:16 UTC (permalink / raw)
To: Sage Weil, Xing Lin; +Cc: ceph-devel
[-- Attachment #1: Type: text/plain, Size: 1702 bytes --]
On 02/11/2013 08:03, Sage Weil wrote:
> Hi!
>
> On Sat, 2 Nov 2013, Xing Lin wrote:
>> Free allocated memory before return because of NULL input
>>
>> Signed-off-by: Xing Lin <xinglin@cs.utah.edu>
>> ---
>> 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;
>> + }
>
> 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
>
> sage
>
>
>>
>> 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 majordomo@vger.kernel.org
>> 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 majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Loïc Dachary, Artisan Logiciel Libre
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] osd/erasurecode: Fix memory leak in jerasure_matrix_to_bitmatrix()
2013-11-02 9:16 ` Loic Dachary
@ 2013-11-04 10:44 ` philippe.raipin
2013-11-04 14:29 ` Loic Dachary
0 siblings, 1 reply; 5+ messages in thread
From: philippe.raipin @ 2013-11-04 10:44 UTC (permalink / raw)
To: loic, sage, xinglin; +Cc: ceph-devel
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 : ceph-devel-owner@vger.kernel.org [mailto:ceph-devel-owner@vger.kernel.org] De la part de Loic Dachary
Envoyé : samedi 2 novembre 2013 10:17
À : Sage Weil; Xing Lin
Cc : ceph-devel@vger.kernel.org
Objet : Re: [PATCH] osd/erasurecode: Fix memory leak in jerasure_matrix_to_bitmatrix()
On 02/11/2013 08:03, Sage Weil wrote:
> Hi!
>
> On Sat, 2 Nov 2013, Xing Lin wrote:
>> Free allocated memory before return because of NULL input
>>
>> Signed-off-by: Xing Lin <xinglin@cs.utah.edu>
>> ---
>> 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;
>> + }
>
> 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
>
> sage
>
>
>>
>> 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 majordomo@vger.kernel.org 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 majordomo@vger.kernel.org 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] osd/erasurecode: Fix memory leak in jerasure_matrix_to_bitmatrix()
2013-11-04 10:44 ` philippe.raipin
@ 2013-11-04 14:29 ` Loic Dachary
0 siblings, 0 replies; 5+ messages in thread
From: Loic Dachary @ 2013-11-04 14:29 UTC (permalink / raw)
To: philippe.raipin; +Cc: ceph-devel
[-- Attachment #1: Type: text/plain, Size: 2686 bytes --]
On 04/11/2013 18:44, philippe.raipin@orange.com 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
> Cheers,
> Philippe
>
>
> -----Message d'origine-----
> De : ceph-devel-owner@vger.kernel.org [mailto:ceph-devel-owner@vger.kernel.org] De la part de Loic Dachary
> Envoyé : samedi 2 novembre 2013 10:17
> À : Sage Weil; Xing Lin
> Cc : ceph-devel@vger.kernel.org
> Objet : Re: [PATCH] osd/erasurecode: Fix memory leak in jerasure_matrix_to_bitmatrix()
>
>
>
> On 02/11/2013 08:03, Sage Weil wrote:
>> Hi!
>>
>> On Sat, 2 Nov 2013, Xing Lin wrote:
>>> Free allocated memory before return because of NULL input
>>>
>>> Signed-off-by: Xing Lin <xinglin@cs.utah.edu>
>>> ---
>>> 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;
>>> + }
>>
>> 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
>
>>
>> sage
>>
>>
>>>
>>> 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 majordomo@vger.kernel.org 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 majordomo@vger.kernel.org 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 majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Loïc Dachary, Artisan Logiciel Libre
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-11-04 14:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-02 6:58 [PATCH] osd/erasurecode: Fix memory leak in jerasure_matrix_to_bitmatrix() Xing Lin
2013-11-02 7:03 ` Sage Weil
2013-11-02 9:16 ` Loic Dachary
2013-11-04 10:44 ` philippe.raipin
2013-11-04 14:29 ` Loic Dachary
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.