RDMA/rxe: check for error
Subsystems (2)
PATCH v2 1/1 RDMA/rxe: check for error
The commit 'ff23dfa13457' modified rxe_create_mmap_info() to return error code and also NULL but missed fixing codes which called rxe_create_mmap_info(). Modify rxe_create_mmap_info() to only return errorcode and fix error checking after rxe_create_mmap_info() was called.
--- drivers/infiniband/sw/rxe/rxe_mmap.c | 2 +- drivers/infiniband/sw/rxe/rxe_queue.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/infiniband/sw/rxe/rxe_mmap.c +1 -1
@@ -151,7 +151,7 @@ struct rxe_mmap_info *rxe_create_mmap_info(struct rxe_dev *rxe, u32 size, ip =kmalloc (sizeof (*ip),GFP_KERNEL );if (!ip) -return NULL ; +return ERR_PTR (-ENOMEM ); size =PAGE_ALIGN (size);
drivers/infiniband/sw/rxe/rxe_queue.c +4 -2
@@ -45,8 +45,10 @@ 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 (ip)) { + err =PTR_ERR (ip); goto err1; + } err =copy_to_user (outbuf, &ip->info,sizeof (ip->info));if (err)
@@ -64,7 +66,7 @@ int do_mmap_info(struct rxe_dev *rxe, struct mminfo __user *outbuf, err2:kfree (ip); err1: -return -EINVAL ; +return err; }inline void rxe_queue_reset (struct rxe_queue *q)
Signature · 1 line
2.11.0
In the commit log,
ff23dfa13457 ("IB: Pass only ib_udata in function prototypes") is better than commit 'ff23dfa13457'?
-----Original Message-----
From: Sudip Mukherjee <[email protected]>
Sent: Sunday, April 26, 2020 7:36 AM
To: Yanjun Zhu <[email protected]>; Doug Ledford <[email protected]>; Jason Gunthorpe <[email protected]>
Cc: [email protected]; [email protected]; Sudip Mukherjee <[email protected]>
Subject: [PATCH v2] RDMA/rxe: check for error
The commit 'ff23dfa13457' modified rxe_create_mmap_info() to return error code and also NULL but missed fixing codes which called rxe_create_mmap_info(). Modify rxe_create_mmap_info() to only return errorcode and fix error checking after rxe_create_mmap_info() was called.
--- drivers/infiniband/sw/rxe/rxe_mmap.c | 2 +- drivers/infiniband/sw/rxe/rxe_queue.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/infiniband/sw/rxe/rxe_mmap.c +1 -1
@@ -151,7 +151,7 @@ struct rxe_mmap_info *rxe_create_mmap_info(struct rxe_dev *rxe, u32 size, ip =kmalloc (sizeof (*ip),GFP_KERNEL );if (!ip) -return NULL ; +return ERR_PTR (-ENOMEM ); size =PAGE_ALIGN (size);
drivers/infiniband/sw/rxe/rxe_queue.c +4 -2
@@ -45,8 +45,10 @@ 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 (ip)) { + err =PTR_ERR (ip); goto err1; + } err =copy_to_user (outbuf, &ip->info,sizeof (ip->info));if (err)
@@ -64,7 +66,7 @@ int do_mmap_info(struct rxe_dev *rxe, struct mminfo __user *outbuf, err2:kfree (ip); err1: -return -EINVAL ; +return err; }inline void rxe_queue_reset (struct rxe_queue *q)
--
2.11.0
Jason Gunthorpe
AppliedQuoted 6 lines · Sudip Mukherjee
The commit '
ff23dfa13457' modifiedrxe_create_mmap_info()to return error code and also NULL but missed fixing codes which calledrxe_create_mmap_info(). Modifyrxe_create_mmap_info()to only return errorcode and fix error checking afterrxe_create_mmap_info()was called.
Quoted 8 lines
Fixes ff23dfa13457 ("IB: Pass only ib_udata in function prototypes")Cc [email protected] [5.4+]Signed-off-by Sudip Mukherjee <[email protected]>Signed-off-by Sudip Mukherjee <[email protected]>--- drivers/infiniband/sw/rxe/rxe_mmap.c | 2 +- drivers/infiniband/sw/rxe/rxe_queue.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)
Applied to for-rc, thanks
Jason