From patchwork Tue May 3 02:29:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Chang X-Patchwork-Id: 748802 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p432XIao026386 for ; Tue, 3 May 2011 02:33:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754319Ab1ECCdS (ORCPT ); Mon, 2 May 2011 22:33:18 -0400 Received: from mail-pw0-f46.google.com ([209.85.160.46]:60794 "EHLO mail-pw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753649Ab1ECCdR (ORCPT ); Mon, 2 May 2011 22:33:17 -0400 Received: by pwi15 with SMTP id 15so2932094pwi.19 for ; Mon, 02 May 2011 19:33:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=wHqPnlAerxYYghVjf3gmJ04NX0ZjqD41F1GTy7H+YWc=; b=YakzlUVOh5R3uLcWYEQnCSKqju9zG8YSFILTUoIEiB2NECCCdehjWrTJcIUj1LJ5nz 8/LGUBuT2IHWQVLauIFXTvNQQqGBe8pIgn+dOfcmjfWtWmzdq7ywgkxtekfRM224sGB3 wqg1Cp4H8/SWiVKAcqqf/FqvnU1RhWlHF9ba0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=xXyDGpGYuRb8NuVdGAyJ7AX6jJstRd4lioQSBXw6tN7+xE03HMo4uB12O88MFNitvz UY5SbW92lI6x8wJgWIiVY3yMEqGFRrfpwHSvZ2tcxCcHes4rwVy31WGdVHxtALMuIm8q 3+OuMh2J6Z11W1FXKtXcM6b2mLCrxjajzbngc= Received: by 10.68.17.6 with SMTP id k6mr9095119pbd.191.1304389997186; Mon, 02 May 2011 19:33:17 -0700 (PDT) Received: from localhost.localdomain ([122.146.30.126]) by mx.google.com with ESMTPS id t9sm4191126pbq.31.2011.05.02.19.33.14 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 02 May 2011 19:33:16 -0700 (PDT) From: Henry C Chang To: ceph-devel@vger.kernel.org Cc: Henry C Chang Subject: [PATCH] libceph: fix ceph_msg_new error path Date: Tue, 3 May 2011 02:29:56 +0000 Message-Id: <1304389796-11363-1-git-send-email-henry_c_chang@tcloudcomputing.com> X-Mailer: git-send-email 1.7.2.3 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.6 (demeter2.kernel.org [140.211.167.43]); Tue, 03 May 2011 02:33:19 +0000 (UTC) If memory allocation failed, calling ceph_msg_put() will cause GPF since some of ceph_msg variables are not initialized first. Fix Bug #970. Signed-off-by: Henry C Chang --- net/ceph/messenger.c | 26 +++++++++++++------------- 1 files changed, 13 insertions(+), 13 deletions(-) diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 05f3578..e15a82c 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -2267,6 +2267,19 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags) m->more_to_follow = false; m->pool = NULL; + /* middle */ + m->middle = NULL; + + /* data */ + m->nr_pages = 0; + m->page_alignment = 0; + m->pages = NULL; + m->pagelist = NULL; + m->bio = NULL; + m->bio_iter = NULL; + m->bio_seg = 0; + m->trail = NULL; + /* front */ if (front_len) { if (front_len > PAGE_CACHE_SIZE) { @@ -2286,19 +2299,6 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags) } m->front.iov_len = front_len; - /* middle */ - m->middle = NULL; - - /* data */ - m->nr_pages = 0; - m->page_alignment = 0; - m->pages = NULL; - m->pagelist = NULL; - m->bio = NULL; - m->bio_iter = NULL; - m->bio_seg = 0; - m->trail = NULL; - dout("ceph_msg_new %p front %d\n", m, front_len); return m;