On Fri, May 25, 2018 at 03:19:59PM -0600, Jason Gunthorpe wrote: > The latest tumbleweed version of gcc reports: > > ../librdmacm/cma.c: In function 'rdma_create_ep': > ../librdmacm/cma.c:2427:24: warning: 'cm_id' may be used uninitialized in this function [-Wmaybe-uninitialized] > id_priv->connect_len = res->ai_connect_len; > > And indeed if write() returns 0, then there is a problem in this function. > Add the missing sanitizing of ret that all other places that call write() > have. > > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx> > --- > librdmacm/cma.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/librdmacm/cma.c b/librdmacm/cma.c > index 2b36e89b26db1f..7f592867c8aa2b 100644 > --- a/librdmacm/cma.c > +++ b/librdmacm/cma.c > @@ -538,8 +538,10 @@ static int rdma_create_id2(struct rdma_event_channel *channel, > cmd.qp_type = qp_type; > > ret = write(id_priv->id.channel->fd, &cmd, sizeof cmd); > - if (ret != sizeof cmd) > + if (ret != sizeof cmd) { > + ret = (ret >= 0) ? ERR(ENODATA) : -1; > goto err; > + } > > VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp); If you are touching that line, can you please write sizeof(cmd) and not "sizeof cmd"? Thanks, Reviewed-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
Attachment:
signature.asc
Description: PGP signature