[PATCH rdma-core] librdmacm: Fix return code from rdma_create_id2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);
 
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux