@@ -116,21 +116,30 @@ static bool con_flag_valid(unsigned long con_flag)
static void con_flag_clear(struct ceph_connection *con, unsigned long con_flag)
{
- BUG_ON(!con_flag_valid(con_flag));
+ if (WARN_ON(!con_flag_valid(con_flag))) {
+ pr_warn("con_flag_clear called with an invalid flag\n");
+ return;
+ }
clear_bit(con_flag, &con->flags);
}
static void con_flag_set(struct ceph_connection *con, unsigned long con_flag)
{
- BUG_ON(!con_flag_valid(con_flag));
+ if (WARN_ON(!con_flag_valid(con_flag))) {
+ pr_warn("con_flag_set called with an invalid flag\n");
+ return;
+ }
set_bit(con_flag, &con->flags);
}
static bool con_flag_test(struct ceph_connection *con, unsigned long con_flag)
{
- BUG_ON(!con_flag_valid(con_flag));
+ if (WARN_ON(!con_flag_valid(con_flag))) {
+ pr_warn("con_flag_test called with an invalid flag\n");
+ return false;
+ }
return test_bit(con_flag, &con->flags);
}
@@ -138,7 +147,10 @@ static bool con_flag_test(struct ceph_connection *con, unsigned long con_flag)
static bool con_flag_test_and_clear(struct ceph_connection *con,
unsigned long con_flag)
{
- BUG_ON(!con_flag_valid(con_flag));
+ if (WARN_ON(!con_flag_valid(con_flag))) {
+ pr_warn("con_flag_test_and_clear called with an invalid flag\n");
+ return false;
+ }
return test_and_clear_bit(con_flag, &con->flags);
}
@@ -146,7 +158,10 @@ static bool con_flag_test_and_clear(struct ceph_connection *con,
static bool con_flag_test_and_set(struct ceph_connection *con,
unsigned long con_flag)
{
- BUG_ON(!con_flag_valid(con_flag));
+ if (WARN_ON(!con_flag_valid(con_flag))) {
+ pr_warn("con_flag_test_and_set called with an invalid flag\n");
+ return false;
+ }
return test_and_set_bit(con_flag, &con->flags);
}
This patch replaces BUG_ON() with WARN_ON() and an appropriate warning message and exit since the condition verified is not influenced by user input. Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com> --- net/ceph/messenger.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)