linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] RDMA/rxe: check for error
@ 2020-04-23 10:48 Sudip Mukherjee
  2020-04-24  1:17 ` Yanjun Zhu
  2020-04-24 18:30 ` Jason Gunthorpe
  0 siblings, 2 replies; 3+ messages in thread
From: Sudip Mukherjee @ 2020-04-23 10:48 UTC (permalink / raw)
  To: Zhu Yanjun, Doug Ledford, Jason Gunthorpe
  Cc: linux-kernel, linux-rdma, 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.

Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
 drivers/infiniband/sw/rxe/rxe_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_queue.c b/drivers/infiniband/sw/rxe/rxe_queue.c
index ff92704de32f..ef438ce4fcfa 100644
--- a/drivers/infiniband/sw/rxe/rxe_queue.c
+++ b/drivers/infiniband/sw/rxe/rxe_queue.c
@@ -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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] RDMA/rxe: check for error
  2020-04-23 10:48 [PATCH] RDMA/rxe: check for error Sudip Mukherjee
@ 2020-04-24  1:17 ` Yanjun Zhu
  2020-04-24 18:30 ` Jason Gunthorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Yanjun Zhu @ 2020-04-24  1:17 UTC (permalink / raw)
  To: Sudip Mukherjee, Doug Ledford, Jason Gunthorpe; +Cc: linux-kernel, linux-rdma

Thanks,
Reviewed-by: Zhu Yanjun <yanjunz@mellanox.com>

-----Original Message-----
From: Sudip Mukherjee <sudipm.mukherjee@gmail.com> 
Sent: Thursday, April 23, 2020 6:48 PM
To: Yanjun Zhu <yanjunz@mellanox.com>; Doug Ledford <dledford@redhat.com>; Jason Gunthorpe <jgg@ziepe.ca>
Cc: linux-kernel@vger.kernel.org; linux-rdma@vger.kernel.org; Sudip Mukherjee <sudipm.mukherjee@gmail.com>
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.

Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
 drivers/infiniband/sw/rxe/rxe_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_queue.c b/drivers/infiniband/sw/rxe/rxe_queue.c
index ff92704de32f..ef438ce4fcfa 100644
--- a/drivers/infiniband/sw/rxe/rxe_queue.c
+++ b/drivers/infiniband/sw/rxe/rxe_queue.c
@@ -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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] RDMA/rxe: check for error
  2020-04-23 10:48 [PATCH] RDMA/rxe: check for error Sudip Mukherjee
  2020-04-24  1:17 ` Yanjun Zhu
@ 2020-04-24 18:30 ` Jason Gunthorpe
  1 sibling, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2020-04-24 18:30 UTC (permalink / raw)
  To: Sudip Mukherjee; +Cc: Zhu Yanjun, Doug Ledford, linux-kernel, linux-rdma

On Thu, Apr 23, 2020 at 11:48:13AM +0100, Sudip Mukherjee wrote:
> 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.
> 
> Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
>  drivers/infiniband/sw/rxe/rxe_queue.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/sw/rxe/rxe_queue.c b/drivers/infiniband/sw/rxe/rxe_queue.c
> index ff92704de32f..ef438ce4fcfa 100644
> +++ b/drivers/infiniband/sw/rxe/rxe_queue.c
> @@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-24 18:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-23 10:48 [PATCH] RDMA/rxe: check for error Sudip Mukherjee
2020-04-24  1:17 ` Yanjun Zhu
2020-04-24 18:30 ` 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).