From patchwork Wed Oct 30 08:33:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 3113501 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E8F16BF924 for ; Wed, 30 Oct 2013 08:33:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B71A22021E for ; Wed, 30 Oct 2013 08:33:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2649D201FB for ; Wed, 30 Oct 2013 08:33:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752502Ab3J3IdX (ORCPT ); Wed, 30 Oct 2013 04:33:23 -0400 Received: from m199-177.yeah.net ([123.58.177.199]:56349 "EHLO m199-177.yeah.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752401Ab3J3IdV (ORCPT ); Wed, 30 Oct 2013 04:33:21 -0400 Received: from localhost.localdomain (unknown [222.240.177.34]) by m199-177.yeah.net (HMail) with ESMTPA id CEBB71100F53; Wed, 30 Oct 2013 16:33:18 +0800 (CST) From: Li Wang To: Cc: Sage Weil , Li Wang Subject: [PATCH] ceph: Fix memory leak in chain_listxattr() Date: Wed, 30 Oct 2013 16:33:13 +0800 Message-Id: <1383121993-18876-1-git-send-email-liwang@ubuntukylin.com> X-Mailer: git-send-email 1.7.9.5 X-HM-Spam-Status: e1koWUFPN1dZCBgUCR5ZQUhCVUtNSUJCTkJKS01PT05IV1kJDhceCFlBWS grPSQoND0vPToyNyQyNSQzPjo*PilBTVVKSEJANiMkIj4oJDI1JDM#Oj8#KUFLVUhPSUArLykkNT QkMjUkMz46Pz4pQUlVQ05DQDg0LjUvKSIkODVBS1VJTUNAKT48MjQ1JDooMjpBSFVPT01AKyk0LT I1OD4kMy41OjVBQlVCSk5APyI1OjYyOCQyKyQ1NCQyNSQzPjo*PilBS1VMQ0JAPzAyNiQ1NDU#QU tVS0ApPjo3JDIrJDI1JCk5NyQyNSQzPjo*PilBTFVLS0NANi43LzIkKTgrLyQ*Mj09Pik#NS8kMj UkMz46Pz4pQU9VS0tJQDIrJEhLJDYyNS4vPiQ4NS8kSyROS0FLVUtAMiskSiQzNC4pJDg1LyRLJE pLS0FLVUtAMiskSiQ2MjUuLz4kODUvJEskSktBS1VLQDIrJE4kNjI1Li8#JDg1LyRLJEpLQUtVS0 AyKyQvND86IiQ4NS8kSyRKS0tBS1VMSk1AKC45JD5BSlVOTkA9NSQoLjkkPjUsNCk*KCQzNzEkSk tLSUtKQUtVSUNAPTUkPSk#PiQzNzEkS0xLTktPQUpVTE5ZBg++ X-HM-Sender-Digest: e1kSHx4VD1lBWUc6MQg6Cjo4LDo4EDorKjhIOj4qOkMwCjFVSlVKSENI SklKQkJDQkJLVTMWGhIXVRcSDBoVHDsOGQ4VDw4QAhcSFVUYFBZFWVdZDB4ZWUEdGhcIHldZCAFZ QUpJTEk3V1kSC1lBWUlJSVVJT0tVSkxMVUhPWQY+ Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Free allocated memory before return Signed-off-by: Li Wang --- src/os/chain_xattr.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/os/chain_xattr.cc b/src/os/chain_xattr.cc index 62733e3..0859564 100644 --- a/src/os/chain_xattr.cc +++ b/src/os/chain_xattr.cc @@ -354,8 +354,10 @@ int chain_listxattr(const char *fn, char *names, size_t len) { return -ENOMEM; r = sys_listxattr(fn, full_buf, total_len); - if (r < 0) + if (r < 0) { + goto done; return r; + } char *p = full_buf; const char *end = full_buf + r;