[PATCH 1/2] net: ceph: messenger: change BUG_ON() to WARN_ON() from ceph_con_in_msg_alloc()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <ciorneiioana@xxxxxxxxx>
---
 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 {
-- 
2.6.4

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux