[ofa-general] Re: [PATCH] mad.c: Fix memory leak in switch handling and improve error handling

Roland Dreier rdreier at cisco.com
Mon Jul 30 13:45:00 PDT 2007


I'm having a hard time seeing what this does exactly.  It seems that
the current code

		} else if (port_priv->device->node_type == RDMA_NODE_IB_SWITCH) {
			/* forward case for switches */
			memcpy(response, recv, sizeof(*response));

will blindly dereference response even if the allocation failed, so
the first chunk that bails out if allocating response seems to be
fixing this.  Anyway this seems like an unrelated change to the rest
of the patch.

I guess the leak fix is:

 > -                       if (!agent_send_response(&response->mad.mad,

 > +                       agent_send_response(&response->mad.mad,

but now you're ignoring the return value of that function.
Hmm... seems that the only other caller also ignores the return
value too.  Should agent_send_response() just become a void function,
since it doesn't seem as if there's anything useful to do with the
return value anyway?

 - R.



More information about the general mailing list