IB/mad: Remove improper use of BUG_ON
Subsystems (4)
PATCH 1/1 IB/mad: Remove improper use of BUG_ON
From: Ira Weiny <[email protected]>
commit 97f229a8515f932e5adc6cdfa18cc1440235b9fd IB/mad: Add support for additional MAD info to/from drivers
added BUG_ON's which were inappropriate for a condition which should never happen. Change these to be WARN_ON_ONCE as a debugging aid.
--- drivers/infiniband/hw/ehca/ehca_sqp.c | 5 +++-- drivers/infiniband/hw/ipath/ipath_mad.c | 5 +++-- drivers/infiniband/hw/mlx4/mad.c | 5 +++-- drivers/infiniband/hw/mlx5/mad.c | 5 +++-- drivers/infiniband/hw/mthca/mthca_mad.c | 5 +++-- drivers/infiniband/hw/ocrdma/ocrdma_ah.c | 5 +++-- drivers/infiniband/hw/qib/qib_mad.c | 5 +++-- 7 files changed, 21 insertions(+), 14 deletions(-)
drivers/infiniband/hw/ehca/ehca_sqp.c +3 -2
@@ -226,8 +226,9 @@ int ehca_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,const struct ib_mad *in_mad = (const struct ib_mad *)in;struct ib_mad *out_mad = (struct ib_mad *)out; -BUG_ON (in_mad_size !=sizeof (*in_mad) || - *out_mad_size !=sizeof (*out_mad)); +if (WARN_ON_ONCE (in_mad_size !=sizeof (*in_mad) || + *out_mad_size !=sizeof (*out_mad))) +return IB_MAD_RESULT_FAILURE ;if (!port_num || port_num > ibdev->phys_port_cnt || !in_wc)return IB_MAD_RESULT_FAILURE ;
drivers/infiniband/hw/ipath/ipath_mad.c +3 -2
@@ -1499,8 +1499,9 @@ int ipath_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,const struct ib_mad *in_mad = (const struct ib_mad *)in;struct ib_mad *out_mad = (struct ib_mad *)out; -BUG_ON (in_mad_size !=sizeof (*in_mad) || - *out_mad_size !=sizeof (*out_mad)); +if (WARN_ON_ONCE (in_mad_size !=sizeof (*in_mad) || + *out_mad_size !=sizeof (*out_mad))) +return IB_MAD_RESULT_FAILURE ;switch (in_mad->mad_hdr.mgmt_class) {case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE :
drivers/infiniband/hw/mlx4/mad.c +3 -2
@@ -876,8 +876,9 @@ int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,const struct ib_mad *in_mad = (const struct ib_mad *)in;struct ib_mad *out_mad = (struct ib_mad *)out; -BUG_ON (in_mad_size !=sizeof (*in_mad) || - *out_mad_size !=sizeof (*out_mad)); +if (WARN_ON_ONCE (in_mad_size !=sizeof (*in_mad) || + *out_mad_size !=sizeof (*out_mad))) +return IB_MAD_RESULT_FAILURE ;switch (rdma_port_get_link_layer (ibdev, port_num)) {case IB_LINK_LAYER_INFINIBAND :
drivers/infiniband/hw/mlx5/mad.c +3 -2
@@ -68,8 +68,9 @@ int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,const struct ib_mad *in_mad = (const struct ib_mad *)in;struct ib_mad *out_mad = (struct ib_mad *)out; -BUG_ON (in_mad_size !=sizeof (*in_mad) || - *out_mad_size !=sizeof (*out_mad)); +if (WARN_ON_ONCE (in_mad_size !=sizeof (*in_mad) || + *out_mad_size !=sizeof (*out_mad))) +return IB_MAD_RESULT_FAILURE ; slid = in_wc ? in_wc->slid :be16_to_cpu (IB_LID_PERMISSIVE );
drivers/infiniband/hw/mthca/mthca_mad.c +3 -2
@@ -209,8 +209,9 @@ int mthca_process_mad(struct ib_device *ibdev,const struct ib_mad *in_mad = (const struct ib_mad *)in;struct ib_mad *out_mad = (struct ib_mad *)out; -BUG_ON (in_mad_size !=sizeof (*in_mad) || - *out_mad_size !=sizeof (*out_mad)); +if (WARN_ON_ONCE (in_mad_size !=sizeof (*in_mad) || + *out_mad_size !=sizeof (*out_mad))) +return IB_MAD_RESULT_FAILURE ;/* Forward locally generated traps to the SM */ if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP &&
drivers/infiniband/hw/ocrdma/ocrdma_ah.c +3 -2
@@ -215,8 +215,9 @@ int ocrdma_process_mad(struct ib_device *ibdev,const struct ib_mad *in_mad = (const struct ib_mad *)in;struct ib_mad *out_mad = (struct ib_mad *)out; -BUG_ON (in_mad_size !=sizeof (*in_mad) || - *out_mad_size !=sizeof (*out_mad)); +if (WARN_ON_ONCE (in_mad_size !=sizeof (*in_mad) || + *out_mad_size !=sizeof (*out_mad))) +return IB_MAD_RESULT_FAILURE ;switch (in_mad->mad_hdr.mgmt_class) {case IB_MGMT_CLASS_PERF_MGMT :
drivers/infiniband/hw/qib/qib_mad.c +3 -2
@@ -2412,8 +2412,9 @@ int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port,const struct ib_mad *in_mad = (const struct ib_mad *)in;struct ib_mad *out_mad = (struct ib_mad *)out; -BUG_ON (in_mad_size !=sizeof (*in_mad) || - *out_mad_size !=sizeof (*out_mad)); +if (WARN_ON_ONCE (in_mad_size !=sizeof (*in_mad) || + *out_mad_size !=sizeof (*out_mad))) +return IB_MAD_RESULT_FAILURE ;switch (in_mad->mad_hdr.mgmt_class) {case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE :
Signature · 6 lines
1.8.2 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: COMMERCIAL: [PATCH] IB/mad: Remove improper use of BUG_ON
In reply to a message not in the archiveQuoted 9 lines · On 6/25/2015 4:50 AM, [email protected] wrote:
From: Ira Weiny<[email protected]>
commit
97f229a8515f932e5adc6cdfa18cc1440235b9fdIB/mad: Add support for additional MAD info to/from driversadded BUG_ON's which were inappropriate for a condition which should never happen. Change these to be
WARN_ON_ONCEas a debugging aid.Signed-off-by Ira Weiny<[email protected]>
Ira, you've put the wrong commit id, this isn't the one that appears in Linus tree, also the change-log should be written in a certain way when you fix an earlier commit, see:
We recently added BUG_ON's which were inappropriate for a condition which should never happen. Change these to be WARN_ON_ONCE as a debugging aid.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html