Skip to content

Commit 7d9ae80

Browse files
Bob Pearsonjgunthorpe
authored andcommitted
RDMA/rxe: Fix coding error in rxe_recv.c
check_type_state() in rxe_recv.c is written as if the type bits in the packet opcode were a bit mask which is not correct. This patch corrects this code to compare all 3 type bits to the required type. Fixes: 8700e3e ("Soft RoCE driver") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bob Pearson <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 1317965 commit 7d9ae80

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/infiniband/sw/rxe/rxe_recv.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,34 @@
99
#include "rxe.h"
1010
#include "rxe_loc.h"
1111

12+
/* check that QP matches packet opcode type and is in a valid state */
1213
static int check_type_state(struct rxe_dev *rxe, struct rxe_pkt_info *pkt,
1314
struct rxe_qp *qp)
1415
{
16+
unsigned int pkt_type;
17+
1518
if (unlikely(!qp->valid))
1619
goto err1;
1720

21+
pkt_type = pkt->opcode & 0xe0;
22+
1823
switch (qp_type(qp)) {
1924
case IB_QPT_RC:
20-
if (unlikely((pkt->opcode & IB_OPCODE_RC) != 0)) {
25+
if (unlikely(pkt_type != IB_OPCODE_RC)) {
2126
pr_warn_ratelimited("bad qp type\n");
2227
goto err1;
2328
}
2429
break;
2530
case IB_QPT_UC:
26-
if (unlikely(!(pkt->opcode & IB_OPCODE_UC))) {
31+
if (unlikely(pkt_type != IB_OPCODE_UC)) {
2732
pr_warn_ratelimited("bad qp type\n");
2833
goto err1;
2934
}
3035
break;
3136
case IB_QPT_UD:
3237
case IB_QPT_SMI:
3338
case IB_QPT_GSI:
34-
if (unlikely(!(pkt->opcode & IB_OPCODE_UD))) {
39+
if (unlikely(pkt_type != IB_OPCODE_UD)) {
3540
pr_warn_ratelimited("bad qp type\n");
3641
goto err1;
3742
}

0 commit comments

Comments
 (0)