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

Hal Rosenstock hrosenstock at xsigo.com
Thu Oct 18 08:17:47 PDT 2007


On Thu, 2007-10-18 at 11:08 -0400, Suresh Shelvapille wrote:
> Hal:
> 
> I don't have a copy of the email with a patch but, here is the email chain that I and
> you exchanged. This patch was submitted as part of the memory leak fix and it 
> should have made it to 2.6.23 rc-2 or 3 I think.

OK; but the patch that was actually committed on 8/3
(445d68070c9c02acdda38e6d69bd43096f521035) does not include this so I
think it is needed (again) as that change did not include the removal of
this if clause after the local label. We somehow dropped this. Roland ?

-- Hal

> Thanks,
> Suri
> 
> 
> > > > >
> > > > > mad.c: Fix memory leak in switch handling and improve error handling
> > > > >
> > > > > Signed-off-by: Suresh Shelvapille <suri at baymicrosystems.com>
> > > > > Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
> > > > >
> > > > > diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
> > > > > index bc547f1..6310dc3 100644
> > > > > --- a/drivers/infiniband/core/mad.c
> > > > > +++ b/drivers/infiniband/core/mad.c
> > > > > @@ -1847,11 +1847,6 @@ static void ib_mad_recv_done_handler(struct
> > > > > ib_mad_port_private *port_priv,
> > > > >        struct ib_mad_agent_private *mad_agent;
> > > > >        int port_num;
> > > > >
> > > > > -       response = kmem_cache_alloc(ib_mad_cache, GFP_KERNEL);
> > > > > -       if (!response)
> > > > > -               printk(KERN_ERR PFX "ib_mad_recv_done_handler no memory "
> > > > > -                      "for response buffer\n");
> > > > > -
> > > > >        mad_list = (struct ib_mad_list_head *)(unsigned long)wc->wr_id;
> > > > >        qp_info = mad_list->mad_queue->qp_info;
> > > > >        dequeue_mad(mad_list);
> > > > > @@ -1879,6 +1874,13 @@ static void ib_mad_recv_done_handler(struct
> > > > > ib_mad_port_private *port_priv,
> > > > >        if (!validate_mad(&recv->mad.mad, qp_info->qp->qp_num))
> > > > >                goto out;
> > > > >
> > > > > +       response = kmem_cache_alloc(ib_mad_cache, GFP_KERNEL);
> > > > > +       if (!response) {
> > > > > +               printk(KERN_ERR PFX "ib_mad_recv_done_handler no memory "
> > > > > +                      "for response buffer\n");
> > > > > +               goto out;
> > > > > +       }
> > > > > +
> > > > >        if (port_priv->device->node_type == RDMA_NODE_IB_SWITCH)
> > > > >                port_num = wc->port_num;
> > > > >        else
> > > > > @@ -1914,12 +1916,11 @@ static void ib_mad_recv_done_handler(struct
> > > > > ib_mad_port_private *port_priv,
> > > > >                        response->header.recv_wc.recv_buf.mad =
> > > > > &response->mad.mad;
> > > > >                        response->header.recv_wc.recv_buf.grh = &response->grh;
> > > > >
> > > > > -                       if (!agent_send_response(&response->mad.mad,
> > > > > -                                                &response->grh, wc,
> > > > > -                                                port_priv->device,
> > > > > -
> > > > > smi_get_fwd_port(&recv->mad.smp),
> > > > > -                                                qp_info->qp->qp_num))
> > > > > -                               response = NULL;
> > > > > +                       agent_send_response(&response->mad.mad,
> > > > > +                                           &response->grh, wc,
> > > > > +                                           port_priv->device,
> > > > > +                                           smi_get_fwd_port(&recv->mad.smp),
> > > > > +                                           qp_info->qp->qp_num);
> > > > >
> > > > >                        goto out;
> > > > >                }
> > > > > @@ -1930,15 +1931,6 @@ local:
> > > > >        if (port_priv->device->process_mad) {
> > > > >                int ret;
> > > > >
> > > > > -               if (!response) {
> > > > > -                       printk(KERN_ERR PFX "No memory for response MAD\n");
> > > > > -                       /*
> > > > > -                        * Is it better to assume that
> > > > > -                        * it wouldn't be processed ?
> > > > > -                        */
> > > > > -                       goto out;
> > > > > -               }
> > > > > -
> > > > >                ret = port_priv->device->process_mad(port_priv->device, 0,
> > > > >                                                     port_priv->port_num,
> > > > >                                                     wc, &recv->grh,
> > > >
> > > >
> 
> _______________________________________________
> general mailing list
> general at lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general
> 
> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general



More information about the general mailing list