[ofa-general] [PATCH] IB: dereference of dev->ibdev.iwcm in c2_register_device()

Roland Dreier rdreier at cisco.com
Mon Aug 31 14:10:44 PDT 2009


 > --- a/drivers/infiniband/hw/amso1100/c2_provider.c
 > +++ b/drivers/infiniband/hw/amso1100/c2_provider.c
 > @@ -851,6 +851,10 @@ int c2_register_device(struct c2_dev *dev)
 >  	dev->ibdev.post_recv = c2_post_receive;
 >  
 >  	dev->ibdev.iwcm = kmalloc(sizeof(*dev->ibdev.iwcm), GFP_KERNEL);
 > +	if (dev->ibdev.iwcm == NULL) {
 > +		ret = -ENOMEM;
 > +		goto out1;
 > +	}
 >  	dev->ibdev.iwcm->add_ref = c2_add_ref;
 >  	dev->ibdev.iwcm->rem_ref = c2_rem_ref;
 >  	dev->ibdev.iwcm->get_qp = c2_get_qp;

Looks like a real fix to me -- but then don't we need to kfree() this
memory if any of the later initialization fails (to avoid a leak)?



More information about the general mailing list