[openib-general] [PATCH] libibumad: nit on short mad read

Hal Rosenstock halr at voltaire.com
Wed Aug 9 13:04:41 PDT 2006


Hi Eitan,

On Tue, 2006-08-01 at 06:28, Eitan Zahavi wrote:
> Hi Hal
> 
> This was reported to me by Ishai R. 
> 
> Consider function umad_recv line 810:
> 	if ((n = read(port->dev_fd, umad, sizeof *mad + *length)) <= 
> 	     sizeof *mad + *length) {
> 		DEBUG("mad received by agent %d length %d", mad->agent_id, n);
> 		*length = n - sizeof *mad;
> 		return mad->agent_id;
> 	}
> 
> 	if (n == -EWOULDBLOCK) {
> 		if (!errno)
> 			errno = EWOULDBLOCK;
> 		return n;
> 	}
> 
> Seems that umad.c umad_recv would never go through the second "if" 
> as if the read return n < 0 it will be cought by the first "if".
> 
> Then I have noticed that a wrap around of the returned length is also 
> possible.
> 
> The patch fixes these issue.
> 
> Eitan

Good catches. Thanks. Applied to both trunk and 1.1 branch.

-- Hal






More information about the general mailing list