[ofa-general] [PATCH] libibumad: Fix several issues that were reported by valgrind

Dotan Barak dotanb at dev.mellanox.co.il
Thu Sep 6 05:05:03 PDT 2007


Fix several issues that were reported by valgrind.
(sorry, but i don't have any test suite to check all of the libibumad code 
 for valgrind warnings in the first place ...)

Signed-off-by: Dotan Barak <dotanb at dev.mellanox.co.il>

Index: ofa_1_3_dev_user/src/userspace/management/libibumad/src/umad.c
===================================================================
--- ofa_1_3_dev_user.orig/src/userspace/management/libibumad/src/umad.c	2007-09-05 09:31:53.000000000 +0300
+++ ofa_1_3_dev_user/src/userspace/management/libibumad/src/umad.c	2007-09-06 14:59:42.000000000 +0300
@@ -832,6 +832,9 @@ umad_recv(int portid, void *umad, int *l
 	}
 
 	n = read(port->dev_fd, umad, sizeof *mad + *length);
+
+	VALGRIND_MAKE_MEM_DEFINED(umad, sizeof *mad + *length);
+
 	if ((n >= 0) && (n <= sizeof *mad + *length)) {
 		DEBUG("mad received by agent %d length %d", mad->agent_id, n);
 		if (n > sizeof *mad)
@@ -910,6 +913,8 @@ umad_register_oui(int portid, int mgmt_c
 	else
 		memset(req.method_mask, 0, sizeof req.method_mask);
 
+	VALGRIND_MAKE_MEM_DEFINED(&req, sizeof req);
+
 	if (!ioctl(port->dev_fd, IB_USER_MAD_REGISTER_AGENT, (void *)&req)) {
 		DEBUG("portid %d registered to use agent %d qp %d class 0x%x oui %p",
 			portid, req.id, req.qpn, req.mgmt_class, oui);



More information about the general mailing list