Skip to contentSkip to conversation

RDMA/rxe: check for error

PATCH Superseded Sudip Mukherjee 3 participants 3 messages Apr 23, 2020 – Apr 24, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/rxe: check for error

rxe_create_mmap_info() returns either NULL or an error value in ERR_PTR and we only checked for NULL after return. We should be using IS_ERR_OR_NULL to check for both.

---
 drivers/infiniband/sw/rxe/rxe_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_queue.c +1 -1
index ff92704de32f..ef438ce4fcfa 100644
@@ -45,7 +45,7 @@ int do_mmap_info(struct rxe_dev *rxe, struct mminfo __user *outbuf,
 
 	if (outbuf) {
 		ip = rxe_create_mmap_info(rxe, buf_size, udata, buf);
-		if (!ip)
+		if (IS_ERR_OR_NULL(ip))
 			goto err1;
 
 		err = copy_to_user(outbuf, &ip->info, sizeof(ip->info));
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw

Thanks,

-----Original Message-----
From: Sudip Mukherjee <[email protected]>
Sent: Thursday, April 23, 2020 6:48 PM
To: Yanjun Zhu <[email protected]>; Doug Ledford <[email protected]>; Jason Gunthorpe <[email protected]>
Cc: [email protected]; [email protected]; Sudip Mukherjee <[email protected]>
Subject: [PATCH] RDMA/rxe: check for error

rxe_create_mmap_info() returns either NULL or an error value in ERR_PTR and we only checked for NULL after return. We should be using IS_ERR_OR_NULL to check for both.

---
 drivers/infiniband/sw/rxe/rxe_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_queue.c +1 -1
index ff92704de32f..ef438ce4fcfa 100644
@@ -45,7 +45,7 @@ int do_mmap_info(struct rxe_dev *rxe, struct mminfo __user *outbuf,
 
 	if (outbuf) {
 		ip = rxe_create_mmap_info(rxe, buf_size, udata, buf);
-		if (!ip)
+		if (IS_ERR_OR_NULL(ip))
 			goto err1;
 
 		err = copy_to_user(outbuf, &ip->info, sizeof(ip->info));

--
2.11.0

#2 lore raw
In reply to Sudip Mukherjee
Quoted 12 lines · Sudip Mukherjee

rxe_create_mmap_info() returns either NULL or an error value in ERR_PTR and we only checked for NULL after return. We should be using IS_ERR_OR_NULL to check for both.

 drivers/infiniband/sw/rxe/rxe_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_queue.c +1 -0
index ff92704de32f..ef438ce4fcfa 100644
+++ b/drivers/infiniband/sw/rxe/rxe_queue.c

drivers/infiniband/sw/rxe/rxe_queue.c int do_mmap_info(struct rxe_dev *rxe, struct mminfo __user *outbuf, · line 49

Quoted 6 lines
drivers/infiniband/sw/rxe/rxe_queue.c +1 -1
@@ -45,7 +45,7 @@ int do_mmap_info(struct rxe_dev *rxe, struct mminfo __user *outbuf,
 
 	if (outbuf) {
 		ip = rxe_create_mmap_info(rxe, buf_size, udata, buf);
-		if (!ip)
+		if (IS_ERR_OR_NULL(ip))
 			goto err1;

Same comment as for the rvt patch - do not use IS_ERR_OR_NULL. If a function uses the ERR_PTR stuff then it should not return NULL. Fix rxe_create_mmap_info and check all call sites

Jason