From patchwork Wed Jan 27 12:52:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 8132251 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D1EBFBEEE5 for ; Wed, 27 Jan 2016 10:52:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D8A5B2021A for ; Wed, 27 Jan 2016 10:52:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 10A142022D for ; Wed, 27 Jan 2016 10:52:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932311AbcA0Kwq (ORCPT ); Wed, 27 Jan 2016 05:52:46 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:36376 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754293AbcA0Kwk (ORCPT ); Wed, 27 Jan 2016 05:52:40 -0500 Received: by mail-wm0-f67.google.com with SMTP id l65so2563309wmf.3 for ; Wed, 27 Jan 2016 02:52:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=lC/EvxXFrOFBj3LsS7zhX1BRAcMbexhtwuuoE8qpWro=; b=a+QBqO8mLTlHt9GP2q3VPy0IvjvOZe39Yd1W+41ft1hg+70YuM3A3FDj9tUZdPsBgf 6WK6XQXhjaui/NpVeAvy9LL9VjjAsbBz2bZnnAo+MJBQRFOAzR7M/Ie1toqhPStOPcZa 8VhkkleFrtjvTXNzlBUMAU+mT0aIpOJKUR+rddNuZjw8Dn0H4JLM/llPWghP5pOepRP1 yV6yepaFL2mWhxfMb8zWmWhPljdBPggd+A7Ei4lzum2/0sx47pJyLqwwX5m/MOCr9c7f V625F0YnnP8JISZVOajzviZaP3yFtyYEUcmNsRD7f56t5LmP/o5aLWMyhPov7Z1b+jWy YP3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=lC/EvxXFrOFBj3LsS7zhX1BRAcMbexhtwuuoE8qpWro=; b=NgTmRjFfgH4BXQRvtgR/eIuldgRMGe8Qmmn3YAYkJFIJ8INym5Z4x/n9kwLFX3F/gp OFNiYnC082yBbKMGxbnd6Y/c1Rjx0ghM7YjQK6BuNUCl1d7YoTFWDdDU+Lc1tqMf95PO Z0X7WWdRli4lZ2Z/pH0y0+aiRiQrNyk+i/IlB0c5pi7cK1hcmiMo/gaj2GXOCZ83QsPv sRIunnSJ/S9e5nyY1VMpz5oHFBcC//GnWNd+nCeDB/DaDp0iWvJDYJL1WVVySrI5Odet J1rOC4o+wbklrbA09ByHdvl9D9RjLn+M3NbhimGGD4MoluE4eUKAm+jWq/3ZYHm5DZ65 5kvA== X-Gm-Message-State: AG10YOShMZ+q+warFaVI0kpkYN6z/ZOc1qQIS6vojpcTTUCb7e5hrhN40uf4RXUQnkmc/g== X-Received: by 10.194.115.164 with SMTP id jp4mr28888183wjb.26.1453891959020; Wed, 27 Jan 2016 02:52:39 -0800 (PST) Received: from yoga.localdomain ([62.121.83.220]) by smtp.gmail.com with ESMTPSA id x10sm5588549wjx.8.2016.01.27.02.52.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Jan 2016 02:52:38 -0800 (PST) From: Ioana Ciornei To: ceph-devel@vger.kernel.org Cc: elder@ieee.org, Ioana Ciornei Subject: [PATCH 1/2] net: ceph: messenger: change BUG_ON() to WARN_ON() from ceph_con_in_msg_alloc() Date: Wed, 27 Jan 2016 14:52:27 +0200 Message-Id: <4248c443a77400d6aaeb3bf352eb19406a9ff6e5.1453898892.git.ciorneiioana@gmail.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: References: In-Reply-To: References: Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 This patch replaces the uses of BUG_ON() from the function ceph_con_in_msg_alloc() with WARN_ON() and an exit strategy. There is no reason to crash the kernel if we can warn the user and return an appropriate error code to the above layer in the calling hierarchy. Signed-off-by: Ioana Ciornei --- net/ceph/messenger.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 9cfedf5..9a5e54c 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -3348,8 +3348,14 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip) struct ceph_msg *msg; int ret = 0; - BUG_ON(con->in_msg != NULL); - BUG_ON(!con->ops->alloc_msg); + if (WARN_ON(con->in_msg)) { + con->in_msg = NULL; + return -ENOENT; + } + if (WARN_ON(!con->ops->alloc_msg)) { + con->in_msg = NULL; + return -ENOENT; + } mutex_unlock(&con->mutex); msg = con->ops->alloc_msg(con, hdr, skip); @@ -3360,7 +3366,10 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip) return -EAGAIN; } if (msg) { - BUG_ON(*skip); + if (WARN_ON(*skip)) { + con->in_msg = NULL; + return -ENOENT; + } msg_con_set(msg, con); con->in_msg = msg; } else {