while (--i >= 0) { ib_dereg_mr(sa_dev->port[i].mr); 
while (--i >= 0) 
static void ib_sa_add_one(struct ib_device *device){	struct ib_sa_device *sa_dev;	int s, e, i;	if (device->node_type == IB_NODE_SWITCH)		s = e = 0;	else {		s = 1;		e = device->phys_port_cnt;	}	sa_dev = kmalloc(sizeof *sa_dev +			 (e - s + 1) * sizeof (struct ib_sa_port),			 GFP_KERNEL);	if (!sa_dev)		return;	sa_dev->start_port = s;	sa_dev->end_port   = e;	for (i = 0; i <= e - s; ++i) {		sa_dev->port[i].mr       = NULL;		sa_dev->port[i].sm_ah    = NULL;		sa_dev->port[i].port_num = i + s;		spin_lock_init(&sa_dev->port[i].ah_lock);		sa_dev->port[i].agent =			ib_register_mad_agent(device, i + s, IB_QPT_GSI,					      NULL, 0, send_handler,					      recv_handler, sa_dev);		if (IS_ERR(sa_dev->port[i].agent))			goto err;		sa_dev->port[i].mr = ib_get_dma_mr(sa_dev->port[i].agent->qp->pd,						   IB_ACCESS_LOCAL_WRITE);		if (IS_ERR(sa_dev->port[i].mr)) {			ib_unregister_mad_agent(sa_dev->port[i].agent);			goto err;		}		INIT_WORK(&sa_dev->port[i].update_task,			  update_sm_ah, &sa_dev->port[i]);	}	ib_set_client_data(device, &sa_client, sa_dev);	/*	 * We register our event handler after everything is set up,	 * and then update our cached info after the event handler is	 * registered to avoid any problems if a port changes state	 * during our initialization.	 */	INIT_IB_EVENT_HANDLER(&sa_dev->event_handler, device, ib_sa_event);	if (ib_register_event_handler(&sa_dev->event_handler))		goto err;	for (i = 0; i <= e - s; ++i)		update_sm_ah(&sa_dev->port[i]);	return;err:	while (--i >= 0) {		ib_dereg_mr(sa_dev->port[i].mr);		ib_unregister_mad_agent(sa_dev->port[i].agent);	}	kfree(sa_dev);	return;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/b82cab6b331b51d82f90d2207f3bbfdf09361ac9/sa_query.c/buggy/drivers/infiniband/core/sa_query.c