[ofa-general] Re: [PATCH] mad.c: Fix memory leak in switch handling	and improve error handling
    Hal Rosenstock 
    hal.rosenstock at gmail.com
       
    Mon Jul 30 13:57:24 PDT 2007
    
    
  
On 7/30/07, Roland Dreier <rdreier at cisco.com> wrote:
> 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.
Yes.
> Anyway this seems like an unrelated change to the rest
> of the patch.
Do these need to be 2 separate patches ?
> I guess the leak fix is:
>
>  > -                       if (!agent_send_response(&response->mad.mad,
>
>  > +                       agent_send_response(&response->mad.mad,
Yes (not going to out is the leak fix).
> 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?
It could. Do you want an updated patch (or patches) ? Let me know.
-- Hal
>  - R.
>
    
    
More information about the general
mailing list