@@ -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 {
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@gmail.com> --- net/ceph/messenger.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)