From patchwork Sun Sep 26 08:59:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kulikov Vasiliy X-Patchwork-Id: 209722 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8Q91WMZ031627 for ; Sun, 26 Sep 2010 09:01:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752631Ab0IZI7o (ORCPT ); Sun, 26 Sep 2010 04:59:44 -0400 Received: from mail-ew0-f46.google.com ([209.85.215.46]:59317 "EHLO mail-ew0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751610Ab0IZI7m (ORCPT ); Sun, 26 Sep 2010 04:59:42 -0400 Received: by ewy23 with SMTP id 23so1057366ewy.19 for ; Sun, 26 Sep 2010 01:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=S4D3S1Ejpj36b6JPXyU0ND2KerIgPgE7Yltr3gGMVfE=; b=sEgOXTw2otocYkZFJ2NvyKt5rgKYppPQmJCi2zdc9uzHRHgFGL+fM6PFOKZGFTteKi 0RHFgtUp4lDYQI8kTUSHBEkIZTNhJ+4EqzA/Zg2neN1tswnwy3uMjnfYGBagngbxJ8LE Z98ttBJDa9vSSrC8JNvCGJnA6GcXl3DIRGz6Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=w0e4kS7jguA0yOsaTXDrw9FxCm1/xGtLU3WRW9JZoNsLL8a3ULTYRrd/LpoYm8uc3P 5bfTsr7CdeJQ5DStxUNcNzWXwPbEKrB6Bql2hBbwpmsk7w2jIub9lpGraimrO6Cb07md Nnvf4zkfxAwSNlR3SOfx4UZtxjrTl0CCk9cH8= Received: by 10.213.29.145 with SMTP id q17mr4825497ebc.27.1285491581290; Sun, 26 Sep 2010 01:59:41 -0700 (PDT) Received: from localhost ([91.78.209.69]) by mx.google.com with ESMTPS id z55sm6330171eeh.21.2010.09.26.01.59.39 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 26 Sep 2010 01:59:40 -0700 (PDT) From: Vasiliy Kulikov To: kernel-janitors@vger.kernel.org Cc: Yehuda Sadeh , Sage Weil , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] block: rbd: fixed may leaks Date: Sun, 26 Sep 2010 12:59:37 +0400 Message-Id: <1285491578-32580-1-git-send-email-segooon@gmail.com> X-Mailer: git-send-email 1.7.0.4 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sun, 26 Sep 2010 09:01:32 +0000 (UTC) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index c42f305..83b15dd 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -241,6 +241,7 @@ static struct rbd_client *rbd_client_create(struct ceph_options *opt) rbdc->client = ceph_create_client(opt, rbdc); if (IS_ERR(rbdc->client)) goto out_rbdc; + opt = NULL; /* Now rbdc->client is responsible for opt */ ret = ceph_open_session(rbdc->client); if (ret < 0) @@ -255,13 +256,12 @@ static struct rbd_client *rbd_client_create(struct ceph_options *opt) out_err: ceph_destroy_client(rbdc->client); - return ERR_PTR(ret); - out_rbdc: kfree(rbdc); out_opt: - ceph_destroy_options(opt); - return ERR_PTR(-ENOMEM); + if (opt) + ceph_destroy_options(opt); + return ERR_PTR(ret); } /* @@ -889,8 +889,10 @@ static int rbd_do_op(struct request *rq, rbd_dev->header.block_name, ofs, len, seg_name, &seg_ofs); - if (seg_len < 0) - return seg_len; + if ((s64)seg_len < 0) { + ret = seg_len; + goto done; + } payload_len = (flags & CEPH_OSD_FLAG_WRITE ? seg_len : 0);