All of lore.kernel.org
 help / color / mirror / Atom feed
From: Loic Dachary <loic@dachary.org>
To: philippe.raipin@orange.com
Cc: ceph-devel@vger.kernel.org
Subject: Re: [PATCH] osd/erasurecode: Fix memory leak in jerasure_matrix_to_bitmatrix()
Date: Mon, 04 Nov 2013 22:29:32 +0800	[thread overview]
Message-ID: <5277AF4C.4080309@dachary.org> (raw)
In-Reply-To: <79B40C35CFBE75499839945586B8480B47F95666@FTRDMB02.rd.francetelecom.fr>

[-- 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 --]

      reply	other threads:[~2013-11-04 14:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5277AF4C.4080309@dachary.org \
    --to=loic@dachary.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=philippe.raipin@orange.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.