* [PATCH net-next] svcrdma: Fix an uninitialized variable false warning
@ 2018-12-20 9:49 YueHaibing
2018-12-28 15:36 ` Chuck Lever
0 siblings, 1 reply; 3+ messages in thread
From: YueHaibing @ 2018-12-20 9:49 UTC (permalink / raw)
To: davem, bfields, jlayton, trond.myklebust, anna.schumaker
Cc: linux-kernel, netdev, linux-nfs, jgg, chuck.lever, bvanassche,
YueHaibing
smatch warning this:
net/sunrpc/xprtrdma/svc_rdma_rw.c:351 svc_rdma_post_chunk_ctxt() error: uninitialized symbol 'bad_wr'
net/sunrpc/xprtrdma/verbs.c:1569 rpcrdma_post_recvs() error: uninitialized symbol 'bad_wr'
'bad_wr' is initialized in ib_post_send. But smatch
doesn't know that and warns this.
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
net/sunrpc/xprtrdma/svc_rdma_rw.c | 2 +-
net/sunrpc/xprtrdma/verbs.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/sunrpc/xprtrdma/svc_rdma_rw.c b/net/sunrpc/xprtrdma/svc_rdma_rw.c
index dc19517..0954b25 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_rw.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_rw.c
@@ -308,7 +308,7 @@ static int svc_rdma_post_chunk_ctxt(struct svc_rdma_chunk_ctxt *cc)
struct svcxprt_rdma *rdma = cc->cc_rdma;
struct svc_xprt *xprt = &rdma->sc_xprt;
struct ib_send_wr *first_wr;
- const struct ib_send_wr *bad_wr;
+ const struct ib_send_wr *bad_wr = NULL;
struct list_head *tmp;
struct ib_cqe *cqe;
int ret;
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index 3ddba94..37be70f 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -1518,7 +1518,7 @@ void
rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)
{
struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
- struct ib_recv_wr *wr, *bad_wr;
+ struct ib_recv_wr *wr, *bad_wr = NULL;
int needed, count, rc;
rc = 0;
--
2.7.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] svcrdma: Fix an uninitialized variable false warning
2018-12-20 9:49 [PATCH net-next] svcrdma: Fix an uninitialized variable false warning YueHaibing
@ 2018-12-28 15:36 ` Chuck Lever
2019-01-03 17:41 ` Bart Van Assche
0 siblings, 1 reply; 3+ messages in thread
From: Chuck Lever @ 2018-12-28 15:36 UTC (permalink / raw)
To: YueHaibing, Bart Van Assche
Cc: David S. Miller, Bruce Fields, Jeff Layton, Trond Myklebust,
Anna Schumaker, open list, netdev, Linux NFS Mailing List,
Jason Gunthorpe
> On Dec 20, 2018, at 4:49 AM, YueHaibing <yuehaibing@huawei.com> wrote:
>
> smatch warning this:
> net/sunrpc/xprtrdma/svc_rdma_rw.c:351 svc_rdma_post_chunk_ctxt() error: uninitialized symbol 'bad_wr'
> net/sunrpc/xprtrdma/verbs.c:1569 rpcrdma_post_recvs() error: uninitialized symbol 'bad_wr'
>
> 'bad_wr' is initialized in ib_post_send. But smatch
> doesn't know that and warns this.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
> net/sunrpc/xprtrdma/svc_rdma_rw.c | 2 +-
> net/sunrpc/xprtrdma/verbs.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_rw.c b/net/sunrpc/xprtrdma/svc_rdma_rw.c
> index dc19517..0954b25 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_rw.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_rw.c
> @@ -308,7 +308,7 @@ static int svc_rdma_post_chunk_ctxt(struct svc_rdma_chunk_ctxt *cc)
> struct svcxprt_rdma *rdma = cc->cc_rdma;
> struct svc_xprt *xprt = &rdma->sc_xprt;
> struct ib_send_wr *first_wr;
> - const struct ib_send_wr *bad_wr;
> + const struct ib_send_wr *bad_wr = NULL;
> struct list_head *tmp;
> struct ib_cqe *cqe;
> int ret;
> diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
> index 3ddba94..37be70f 100644
> --- a/net/sunrpc/xprtrdma/verbs.c
> +++ b/net/sunrpc/xprtrdma/verbs.c
> @@ -1518,7 +1518,7 @@ void
> rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)
> {
> struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
> - struct ib_recv_wr *wr, *bad_wr;
> + struct ib_recv_wr *wr, *bad_wr = NULL;
> int needed, count, rc;
>
> rc = 0;
> --
> 2.7.0
Does this need
Fixes: d34ac5cd3a73 ("RDMA, core and ULPs: Declare ib_post_send() and ib_post_recv() arguments const") ???
Bart, any comments?
--
Chuck Lever
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] svcrdma: Fix an uninitialized variable false warning
2018-12-28 15:36 ` Chuck Lever
@ 2019-01-03 17:41 ` Bart Van Assche
0 siblings, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2019-01-03 17:41 UTC (permalink / raw)
To: Chuck Lever, YueHaibing
Cc: David S. Miller, Bruce Fields, Jeff Layton, Trond Myklebust,
Anna Schumaker, open list, netdev, Linux NFS Mailing List,
Jason Gunthorpe
On Fri, 2018-12-28 at 10:36 -0500, Chuck Lever wrote:
> > On Dec 20, 2018, at 4:49 AM, YueHaibing <yuehaibing@huawei.com> wrote:
> >
> > smatch warning this:
> > net/sunrpc/xprtrdma/svc_rdma_rw.c:351 svc_rdma_post_chunk_ctxt() error: uninitialized symbol 'bad_wr'
> > net/sunrpc/xprtrdma/verbs.c:1569 rpcrdma_post_recvs() error: uninitialized symbol 'bad_wr'
> >
> > 'bad_wr' is initialized in ib_post_send. But smatch
> > doesn't know that and warns this.
> >
> > Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> > ---
> > net/sunrpc/xprtrdma/svc_rdma_rw.c | 2 +-
> > net/sunrpc/xprtrdma/verbs.c | 2 +-
> > 2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/sunrpc/xprtrdma/svc_rdma_rw.c b/net/sunrpc/xprtrdma/svc_rdma_rw.c
> > index dc19517..0954b25 100644
> > --- a/net/sunrpc/xprtrdma/svc_rdma_rw.c
> > +++ b/net/sunrpc/xprtrdma/svc_rdma_rw.c
> > @@ -308,7 +308,7 @@ static int svc_rdma_post_chunk_ctxt(struct svc_rdma_chunk_ctxt *cc)
> > struct svcxprt_rdma *rdma = cc->cc_rdma;
> > struct svc_xprt *xprt = &rdma->sc_xprt;
> > struct ib_send_wr *first_wr;
> > - const struct ib_send_wr *bad_wr;
> > + const struct ib_send_wr *bad_wr = NULL;
> > struct list_head *tmp;
> > struct ib_cqe *cqe;
> > int ret;
> > diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
> > index 3ddba94..37be70f 100644
> > --- a/net/sunrpc/xprtrdma/verbs.c
> > +++ b/net/sunrpc/xprtrdma/verbs.c
> > @@ -1518,7 +1518,7 @@ void
> > rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)
> > {
> > struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
> > - struct ib_recv_wr *wr, *bad_wr;
> > + struct ib_recv_wr *wr, *bad_wr = NULL;
> > int needed, count, rc;
> >
> > rc = 0;
> > --
> > 2.7.0
>
> Does this need
>
> Fixes: d34ac5cd3a73 ("RDMA, core and ULPs: Declare ib_post_send() and ib_post_recv() arguments const") ???
>
> Bart, any comments?
Hi Chuck,
My understanding is that the "Fixes:" tag should only be used for patches
that fix bugs. Since this patch addresses a false positive warning reported
by smatch I think that it would be misleading to use the "Fixes:" tag.
Before proceeding with this patch, I think that smatch should be improved.
The following patch namely was not sufficient to suppress the xprtrdma
warning reported by smatch:
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index a3ceed3a040a..498eaa245d1a 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -3327,9 +3327,16 @@ static inline int ib_post_srq_recv(struct ib_srq *srq,
const struct ib_recv_wr **bad_recv_wr)
{
const struct ib_recv_wr *dummy;
-
- return srq->device->ops.post_srq_recv(srq, recv_wr,
- bad_recv_wr ? : &dummy);
+ int ret;
+
+ ret = srq->device->ops.post_srq_recv(srq, recv_wr,
+ bad_recv_wr ? : &dummy);
+#ifdef __CHECKER__
+ /* Tell static analyzers that *bad_send_wr is initialized if ret != 0 */
+ if (ret && bad_send_wr)
+ *bad_send_wr = *bad_send_wr;
+#endif
+ return ret;
}
/**
@@ -3431,8 +3438,15 @@ static inline int ib_post_send(struct ib_qp *qp,
const struct ib_send_wr **bad_send_wr)
{
const struct ib_send_wr *dummy;
+ int ret;
- return qp->device->ops.post_send(qp, send_wr, bad_send_wr ? : &dummy);
+ ret = qp->device->ops.post_send(qp, send_wr, bad_send_wr ? : &dummy);
+#ifdef __CHECKER__
+ /* Tell static analyzers that *bad_send_wr is initialized if ret != 0 */
+ if (ret && bad_send_wr)
+ *bad_send_wr = *bad_send_wr;
+#endif
+ return ret;
}
/**
@@ -3448,8 +3462,15 @@ static inline int ib_post_recv(struct ib_qp *qp,
const struct ib_recv_wr **bad_recv_wr)
{
const struct ib_recv_wr *dummy;
+ int ret;
- return qp->device->ops.post_recv(qp, recv_wr, bad_recv_wr ? : &dummy);
+ ret = qp->device->ops.post_recv(qp, recv_wr, bad_recv_wr ? : &dummy);
+#ifdef __CHECKER__
+ /* Tell static analyzers that *bad_send_wr is initialized if ret != 0 */
+ if (ret && bad_send_wr)
+ *bad_send_wr = *bad_send_wr;
+#endif
+ return ret;
}
struct ib_cq *__ib_alloc_cq(struct ib_device *dev, void *private,
Bart.
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-03 17:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-20 9:49 [PATCH net-next] svcrdma: Fix an uninitialized variable false warning YueHaibing
2018-12-28 15:36 ` Chuck Lever
2019-01-03 17:41 ` Bart Van Assche
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).