All of lore.kernel.org
 help / color / mirror / Atom feed
From: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
To: ceph-devel@vger.kernel.org
Cc: Danny Al-Gaaf <dalgaaf@suse.de>, Sage Weil <sage@inktank.com>
Subject: [PATCH 6/6] rgw/rgw_rest.cc: fix 4K memory leak
Date: Fri,  8 Feb 2013 17:25:03 +0100	[thread overview]
Message-ID: <1360340703-7170-7-git-send-email-danny.al-gaaf@bisect.de> (raw)
In-Reply-To: <1360340703-7170-1-git-send-email-danny.al-gaaf@bisect.de>

Fix 4K memory leak in case RGWClientIO::read() fails in
read_all_chunked_input().

Error from cppcheck was:
Checking src/rgw/rgw_rest.cc...
[src/rgw/rgw_rest.cc:688]: (error) Memory leak: data

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
---
 src/rgw/rgw_rest.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc
index 72aab14..ab3927e 100644
--- a/src/rgw/rgw_rest.cc
+++ b/src/rgw/rgw_rest.cc
@@ -684,8 +684,10 @@ static int read_all_chunked_input(req_state *s, char **pdata, int *plen)
   int read_len = 0, len = 0;
   do {
     int r = s->cio->read(data + len, need_to_read, &read_len);
-    if (r < 0)
+    if (r < 0) {
+      free(data);
       return r;
+    }
 
     len += read_len;
 
-- 
1.8.1.2


      parent reply	other threads:[~2013-02-08 16:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-08 16:24 [PATCH 0/6] Fix some memory leaks in Ceph Danny Al-Gaaf
2013-02-08 16:24 ` [PATCH 1/6] common/fiemap.cc: fix realloc memory leak Danny Al-Gaaf
2013-02-08 16:24 ` [PATCH 2/6] os/FileStore.cc: fix realloc memory leak in error case Danny Al-Gaaf
2013-02-08 16:25 ` [PATCH 3/6] rgw/rgw_xml.cc: " Danny Al-Gaaf
2013-02-08 16:25 ` [PATCH 4/6] wireshark: fix some memory leaks Danny Al-Gaaf
2013-02-08 16:25 ` [PATCH 5/6] SyntheticClient.cc: fix some memory leaks in the error handling Danny Al-Gaaf
2013-02-08 17:47   ` Danny Al-Gaaf
2013-02-08 17:52     ` [PATCH v2 " Danny Al-Gaaf
2013-02-10  6:04   ` [PATCH " Sage Weil
2013-02-10  8:43     ` Danny Al-Gaaf
2013-02-11  2:07       ` Sage Weil
2013-02-08 16:25 ` Danny Al-Gaaf [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=1360340703-7170-7-git-send-email-danny.al-gaaf@bisect.de \
    --to=danny.al-gaaf@bisect.de \
    --cc=ceph-devel@vger.kernel.org \
    --cc=dalgaaf@suse.de \
    --cc=sage@inktank.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.