if (!file->agent[agent_id]) 
if (!__get_agent(file, agent_id)) 
static int ib_umad_reg_agent(struct ib_umad_file *file, unsigned long arg){	struct ib_user_mad_reg_req ureq;	struct ib_mad_reg_req req;	struct ib_mad_agent *agent;	int agent_id;	int ret;	down_write(&file->port->mutex);	if (!file->port->ib_dev) {		ret = -EPIPE;		goto out;	}	if (copy_from_user(&ureq, (void __user *) arg, sizeof ureq)) {		ret = -EFAULT;		goto out;	}	if (ureq.qpn != 0 && ureq.qpn != 1) {		ret = -EINVAL;		goto out;	}	for (agent_id = 0; agent_id < IB_UMAD_MAX_AGENTS; ++agent_id)		if (!file->agent[agent_id])			goto found;	ret = -ENOMEM;	goto out;found:	if (ureq.mgmt_class) {		req.mgmt_class         = ureq.mgmt_class;		req.mgmt_class_version = ureq.mgmt_class_version;		memcpy(req.method_mask, ureq.method_mask, sizeof req.method_mask);		memcpy(req.oui,         ureq.oui,         sizeof req.oui);	}	agent = ib_register_mad_agent(file->port->ib_dev, file->port->port_num,				      ureq.qpn ? IB_QPT_GSI : IB_QPT_SMI,				      ureq.mgmt_class ? &req : NULL,				      ureq.rmpp_version,				      send_handler, recv_handler, file);	if (IS_ERR(agent)) {		ret = PTR_ERR(agent);		goto out;	}	if (put_user(agent_id,		     (u32 __user *) (arg + offsetof(struct ib_user_mad_reg_req, id)))) {		ret = -EFAULT;		ib_unregister_mad_agent(agent);		goto out;	}	file->agent[agent_id] = agent;	ret = 0;out:	up_write(&file->port->mutex);	return ret;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/94382f3562e350ed7c8f7dcd6fc968bdece31328/user_mad.c/clean/drivers/infiniband/core/user_mad.c