* [PATCH for-next] RDMA/rxe: Fix coding error in rxe_recv.c
@ 2021-01-27 21:45 Bob Pearson
2021-02-05 17:57 ` Jason Gunthorpe
0 siblings, 1 reply; 2+ messages in thread
From: Bob Pearson @ 2021-01-27 21:45 UTC (permalink / raw)
To: jgg, zyjzyj2000, linux-rdma; +Cc: Bob Pearson
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: 8700e3e7c485 ("Soft RoCE driver")
Signed-off-by: Bob Pearson <rpearson@hpe.com>
---
drivers/infiniband/sw/rxe/rxe_recv.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/sw/rxe/rxe_recv.c b/drivers/infiniband/sw/rxe/rxe_recv.c
index c9984a28eecc..0c9b857194fe 100644
--- a/drivers/infiniband/sw/rxe/rxe_recv.c
+++ b/drivers/infiniband/sw/rxe/rxe_recv.c
@@ -9,21 +9,26 @@
#include "rxe.h"
#include "rxe_loc.h"
+/* check that QP matches packet opcode type and is in a valid state */
static int check_type_state(struct rxe_dev *rxe, struct rxe_pkt_info *pkt,
struct rxe_qp *qp)
{
+ int pkt_type;
+
if (unlikely(!qp->valid))
goto err1;
+ pkt_type = pkt->opcode & 0xe0;
+
switch (qp_type(qp)) {
case IB_QPT_RC:
- if (unlikely((pkt->opcode & IB_OPCODE_RC) != 0)) {
+ if (unlikely(pkt_type != IB_OPCODE_RC)) {
pr_warn_ratelimited("bad qp type\n");
goto err1;
}
break;
case IB_QPT_UC:
- if (unlikely(!(pkt->opcode & IB_OPCODE_UC))) {
+ if (unlikely(pkt_type != IB_OPCODE_UC)) {
pr_warn_ratelimited("bad qp type\n");
goto err1;
}
@@ -31,7 +36,7 @@ static int check_type_state(struct rxe_dev *rxe, struct rxe_pkt_info *pkt,
case IB_QPT_UD:
case IB_QPT_SMI:
case IB_QPT_GSI:
- if (unlikely(!(pkt->opcode & IB_OPCODE_UD))) {
+ if (unlikely(pkt_type != IB_OPCODE_UD)) {
pr_warn_ratelimited("bad qp type\n");
goto err1;
}
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH for-next] RDMA/rxe: Fix coding error in rxe_recv.c
2021-01-27 21:45 [PATCH for-next] RDMA/rxe: Fix coding error in rxe_recv.c Bob Pearson
@ 2021-02-05 17:57 ` Jason Gunthorpe
0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2021-02-05 17:57 UTC (permalink / raw)
To: Bob Pearson; +Cc: zyjzyj2000, linux-rdma, Bob Pearson
On Wed, Jan 27, 2021 at 03:45:01PM -0600, Bob Pearson wrote:
> 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: 8700e3e7c485 ("Soft RoCE driver")
> Signed-off-by: Bob Pearson <rpearson@hpe.com>
> ---
> drivers/infiniband/sw/rxe/rxe_recv.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
Applied to for-next, thanks
> diff --git a/drivers/infiniband/sw/rxe/rxe_recv.c b/drivers/infiniband/sw/rxe/rxe_recv.c
> index c9984a28eecc..0c9b857194fe 100644
> --- a/drivers/infiniband/sw/rxe/rxe_recv.c
> +++ b/drivers/infiniband/sw/rxe/rxe_recv.c
> @@ -9,21 +9,26 @@
> #include "rxe.h"
> #include "rxe_loc.h"
>
> +/* check that QP matches packet opcode type and is in a valid state */
> static int check_type_state(struct rxe_dev *rxe, struct rxe_pkt_info *pkt,
> struct rxe_qp *qp)
> {
> + int pkt_type;
I fixed this to 'unsigned int'
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-05 18:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-27 21:45 [PATCH for-next] RDMA/rxe: Fix coding error in rxe_recv.c Bob Pearson
2021-02-05 17:57 ` Jason Gunthorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).