* [PATCH][next] RDMA/bnxt_re: Fix uninitialized struct bit field rsvd1
@ 2021-06-23 17:12 Colin King
2021-06-23 17:38 ` Jason Gunthorpe
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-06-23 17:12 UTC (permalink / raw)
To: Selvin Xavier, Devesh Sharma, Naresh Kumar PBS, Doug Ledford,
Jason Gunthorpe, Leon Romanovsky, linux-rdma
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The bit field rsvd1 in resp is not being initialized and garbage data
is being copied from the stack back to userspace via the ib_copy_to_udata
call. Fix this by setting rsvd1 to zero. Also remove some whitespace.
Addresses-Coverity: ("Uninitialized scalar variable")
Fixes: 879740517dab ("RDMA/bnxt_re: Update ABI to pass wqe-mode to user space")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index 5955713234cb..45398f1777aa 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -3880,7 +3880,8 @@ int bnxt_re_alloc_ucontext(struct ib_ucontext *ctx, struct ib_udata *udata)
resp.pg_size = PAGE_SIZE;
resp.cqe_sz = sizeof(struct cq_base);
resp.max_cqd = dev_attr->max_cq_wqes;
- resp.rsvd = 0;
+ resp.rsvd = 0;
+ resp.rsvd1 = 0;
resp.comp_mask |= BNXT_RE_UCNTX_CMASK_HAVE_MODE;
resp.mode = rdev->chip_ctx->modes.wqe_mode;
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][next] RDMA/bnxt_re: Fix uninitialized struct bit field rsvd1
2021-06-23 17:12 [PATCH][next] RDMA/bnxt_re: Fix uninitialized struct bit field rsvd1 Colin King
@ 2021-06-23 17:38 ` Jason Gunthorpe
0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2021-06-23 17:38 UTC (permalink / raw)
To: Colin King
Cc: Selvin Xavier, Devesh Sharma, Naresh Kumar PBS, Doug Ledford,
Leon Romanovsky, linux-rdma, kernel-janitors, linux-kernel
On Wed, Jun 23, 2021 at 06:12:02PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The bit field rsvd1 in resp is not being initialized and garbage data
> is being copied from the stack back to userspace via the ib_copy_to_udata
> call. Fix this by setting rsvd1 to zero. Also remove some whitespace.
>
> Addresses-Coverity: ("Uninitialized scalar variable")
> Fixes: 879740517dab ("RDMA/bnxt_re: Update ABI to pass wqe-mode to user space")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> drivers/infiniband/hw/bnxt_re/ib_verbs.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> index 5955713234cb..45398f1777aa 100644
> +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> @@ -3880,7 +3880,8 @@ int bnxt_re_alloc_ucontext(struct ib_ucontext *ctx, struct ib_udata *udata)
> resp.pg_size = PAGE_SIZE;
> resp.cqe_sz = sizeof(struct cq_base);
> resp.max_cqd = dev_attr->max_cq_wqes;
> - resp.rsvd = 0;
> + resp.rsvd = 0;
> + resp.rsvd1 = 0;
I think I would prefer
struct bnxt_re_uctx_resp resp = {};
This isn't a performance path
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-23 17:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23 17:12 [PATCH][next] RDMA/bnxt_re: Fix uninitialized struct bit field rsvd1 Colin King
2021-06-23 17:38 ` 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).