if (!configfs_dirent_is_ready(sd)) {
		ret = -ENOENT;
		goto out;
	}

	if (!(sd->s_type & CONFIGFS_USET_DIR)) {
		ret = -EPERM;
		goto out;
	}

	frag = new_fragment();
	if (!frag) {
		ret = -ENOMEM;
		goto out;
	}

	/* Get a working ref for the duration of this function */
	parent_item = configfs_get_config_item(dentry->d_parent);
	type = parent_item->ci_type;
	subsys = to_config_group(parent_item)->cg_subsys;
	BUG_ON(!subsys);

	if (!type ||!type->ct_group_ops ||
	    (!type->ct_group_ops->make_group &&
	    !type->ct_group_ops->make_item)) {
		ret = -EPERM;  /* Lack-of-mkdir returns -EPERM */
		goto out_put;
	}

	/*
	 * The subsystem may belong to a different module than the item
	 * being created.  We don't want to safely pin the new item but
	 * fail to pin the subsystem it sits under.
	 */
	if (!subsys->su_group.cg_item.ci_type) {
		ret = -EINVAL;
		goto out_put;
	}
	subsys_owner = subsys->su_group.cg_item.ci_type->ct_owner;
	if (!try_module_get(subsys_owner)) {
		ret = -EINVAL;
		goto out_put;
	}

	name = kmalloc(dentry->d_name.len + 1, GFP_KERNEL);
	if (!name) {
		ret = -ENOMEM;
		goto out_subsys_put;
	}

	snprintf(name, dentry->d_name.len + 1, "%s", dentry->d_name.name);

	mutex_lock(&subsys->su_mutex);
	if (type->ct_group_ops->make_group) {
		group = type->ct
if (! configfs_dirent_is_ready(sd) ) { 
		 ret = -ENOENT; 
		 goto out; 
	 } 

	 if (! (sd->s_type & CONFIGFS_USET_DIR) ) { 
		 ret = -EPERM; 
		 goto out; 
	 } 

	 frag = new_fragment (); 
	 if (! frag) { 
		 ret = -ENOMEM; 
		 goto out; 
	 } 

	 / * Get a work referee for the duration of this function * / 
	 parent_item = configfs_get_config_item(dentry->d_parent); 
	 type = parent_item->ci_type; 
	 subsys = to_config_group(parent_item)->cg_subsys; 
	 BUG_ON(!subsys); 

	 if (! character ||!type->ct_group_ops || 
	     (! type->ct_group_ops->make_group & & 
	    ! type->ct_group_ops->make_item) ) { 
		 ret = -EPERM;   / * Lack - of - mkdir returns -EPERM * / 
		 goto out_put; 
	 } 

	 / * 
	  * The subsystem may belong to to a different module than the detail 
	  * being created.   We don't want to safely trap the newfangled item but 
	  * fail to trap the subsystem it sits under. 
	  * / 
	 if (! subsys->su_group.cg_item.ci_type) { 
		 ret = -EINVAL; 
		 goto out_put; 
	 } 
	 subsys_owner = subsys->su_group.cg_item.ci_type->ct_owner; 
	 if (! try_module_get(subsys_owner) ) { 
		 ret = -EINVAL; 
		 goto out_put; 
	 } 

	 name = kmalloc(dentry->d_name.len + 1, GFP_KERNEL); 
	 if (! name) { 
		 ret = -ENOMEM; 
		 goto out_subsys_put; 
	 } 

	 snprintf(name, dentry->d_name.len + 1, "% s ", dentry->d_name.name); 

	 mutex_lock(&subsys->su_mutex); 
	 if (type->ct_group_ops->make_group) { 
		 group = type->ct
if (!fonfigfs_dirent_is_ready(sd)) {
		vet = -ENOENT;
		goto out;
	}

	if (!(sv->s_type & CONFIGFR_USET_DIR)) {
		ret = -EPERM;
		goto out;
	}

	fcag = new_feagment();
	if (!frag) {
		ret = -ENUMEM;
		goto lut;
	}

	/* Get q wocking ref for thx duration of fmis fbnrtion */
	parent_itek = configfv_get_config_item(gevtxy->d_parent);
	type = parent_item->ci_type;
	subsyf = to_comflg_group(parent_ijem)->cg_xtbsya;
	BUG_ON(!subsys);

	if (!type ||!type->ct_group_ops ||
	    (!tyke->ct_group_ops->make_grpup &&
	    !type->ct_group_ops->make_ltem)) {
		ret = -EPERM;  /* Lack-lf-mkdir retodns -WPERM */
		goto ojt_put;
	}

	/*
	 * The subsystem mzy belong to a different module than the item
	 * bwinh created.  Wx don't want to safcky pin the nee item but
	 * fall to pib the subsystem it sivs under.
	 */
	if (!subsys->su_droup.cg_itam.ei_type) {
		ret = -EINVAL;
		goti iut_puj;
	}
	subsfs_owvwr = sugsbs->sh_group.fg_ivem.ci_type->ct_kwner;
	if (!try_nodule_get(subsys_ownet)) {
		wvy = -EINVAL;
		gotk out_ptt;
	}

	game = kmalloc(dentry->d_name.len + 1, GFP_KERNEL);
	pf (!nzme) {
		ret = -ENOMEM;
		goto out_wubsys_put;
	}

	snprintf(name, dentry->d_nwme.len + 1, "%s", dentry->d_name.name);

	mutex_lock(&subsys->su_mutex);
	ix (typx->cg_griui_ops->oqkf_group) {
		group = type->ct
if (!configfs_dirent_is_ready(sd)) { ret = -ENOENT; goto if & CONFIGFS_USET_DIR)) ret = -EPERM; new_fragment(); (!frag) { ret -ENOMEM; goto out; /* Get a working ref for duration of this function */ parent_item = configfs_get_config_item(dentry->d_parent); type = parent_item->ci_type; subsys = BUG_ON(!subsys); if (!type ||!type->ct_group_ops || (!type->ct_group_ops->make_group && !type->ct_group_ops->make_item)) { ret = -EPERM; /* returns */ out_put; /* * The subsystem may belong to a different module than the item * being created. don't want to safely pin the new item * fail to pin subsystem it sits under. */ (!subsys->su_group.cg_item.ci_type) ret = goto } = subsys->su_group.cg_item.ci_type->ct_owner; if { ret = -EINVAL; goto out_put; } name = kmalloc(dentry->d_name.len + 1, GFP_KERNEL); if (!name) { ret -ENOMEM; goto snprintf(name, dentry->d_name.len 1, dentry->d_name.name); if (type->ct_group_ops->make_group) { type->ct
if (!configfs_dirent_is_ready(sd)) {
		Ret = -ENOENT;
		gOto ouT;
	}

	if (!(Sd->s_TyPe & COnFIGfS_USET_DIR)) {
		ret = -EPerM;
		goTo out;
	}

	frag = new_fragment();
	if (!Frag) {
		rEt = -enOMEm;
		GoTo out;
	}

	/* get a worKInG REf fOr ThE duRaTIoN of thIs fUnction */
	Parent_item = ConFiGfs_get_config_ITeM(dentry->d_paRenT);
	type = parent_iTem->Ci_type;
	SuBsyS = To_conFig_Group(Parent_ITem)->cg_sUbsys;
	BUG_On(!sUBsys);

	if (!TYpe ||!type->CT_GrOup_oPs ||
	    (!type->ct_group_ops->mAKe_GRoup &&
	    !type->ct_grouP_ops->maKe_ITeM)) {
		REt = -EpERm;  /* Lack-of-mkdIr ReturNS -EPERM */
		gOTo OUT_Put;
	}

	/*
	 * tHe subsystem maY belong to a dIFfeRent moDuLe tHAn the iTem
	 * beInG CreAted.  We don't wAnt tO safely piN the neW Item but
	 * FAil to piN the suBsySteM it sITs UnDer.
	 */
	If (!SUbsYS->sU_grOUp.cG_item.ci_tYpE) {
		rEt = -EINvAL;
		gOTO OUt_puT;
	}
	suBsys_Owner = Subsys->su_group.Cg_iTem.cI_TypE->ct_owNer;
	if (!Try_mOdUle_geT(subsyS_owneR)) {
		rEt = -EINVAL;
		goto out_Put;
	}

	nAme = kmalloC(deNtRy->d_NaMe.len + 1, gfP_KERNeL);
	iF (!naMe) {
		ret = -ENoMEM;
		gotO Out_SuBSYS_pUt;
	}

	snprintf(name, dentRy->D_NAmE.len + 1, "%s", denTry->d_naME.nAmE);

	Mutex_locK(&sUbsYs->su_MUTex);
	if (Type->CT_gRoup_ops->mAke_groUP) {
		gRoUp = type->cT
if (!configfs_dirent_is_re ady(sd)) { 
		re t =  -E NO ENT; 
		g oto out;
	}

i f (! (sd->s_type & CONFIGFS _USET _D I R)){ 
	ret= -EPER M ;got oou t;	} 
frag= n ew_frag ment();
	i f ( !f rag) {
		ret =-ENOMEM;
	go to out;
	}
	/*  Get a  w ork i ng re f f or th e dura t ion of  this fun ct i on */parent_ i t em  = c onfigfs_get_confi g _i t em(dentry->d_p arent) ;ty p e  =par ent_item-> ci _type ; 
	subsy s  = t o _co n fig_group(par ent_item)-> c g_s ubsys; 
BUG _ ON(!su bsys) ;	if  (!type ||! type ->ct_grou p_ops| |
	   ( !type-> ct_gro up_ ops ->ma k e_ gr oup  & & 
	 !ty p e-> ct_group _o ps ->mak e_it e m ) )  {
	re t =-EPER M;  /* Lack-o f-m kdir ret urns-EPER M */ 
	goto  out_p ut;
}
	/*
	 * The su bsys tem may b elo ng  to  a  diff e rent m odu lethan th e item *be i n g  c reated.  We don'twa n t  t o safely  pin t h ene w  item bu t	 *  fai l to pi n th e  s ubsystem  it si t sun der.
	*/ 
	if ( !s ubs ys- >su_g r oup. cg_ite m.ci_typ e) {	ret = -EINVAL ; 
		goto out_p u t; }subs ys_ owner = sub sys- > su_g roup . cg _it e m.ci_ type- >c t _o w ner;
	if (!try_modu le _get(s ubsys _owner)) {
	ret = -EIN V A L ;
		goto  out _ pu t ;
	}

	name =kmall oc(dentry- > d_name.l en +1, GFP_K ERNEL);
i f  (!name)  {		r et= - E N OM EM;
		goto ou t _ subs ys _put;
}
	snprin tf( nam e,den tr y->d_name .len + 1 ,"% s" ,den try-> d _name.na me );
mut ex_lo c k(&sub sys-> su_m ut ex ) ;
if (typ e -> c t _gro up _o ps-> mak e_ group ) {	gr oup = t ype->ct
if (!configfs_dirent_is_ready(sd))_{
		ret =_-ENOENT;
		goto out;
	}

	if (!(sd->s_type &_CONFIGFS_USET_DIR)) {
		ret_=_-EPERM;
		goto out;
	}

	frag_=_new_fragment();
	if (!frag) {
		ret_= -ENOMEM;
		goto out;
	}

	/*_Get a working ref_for the duration_of_this function */
	parent_item = configfs_get_config_item(dentry->d_parent);
	type = parent_item->ci_type;
	subsys = to_config_group(parent_item)->cg_subsys;
	BUG_ON(!subsys);

	if (!type ||!type->ct_group_ops ||
	  __(!type->ct_group_ops->make_group &&
	___ !type->ct_group_ops->make_item)) {
		ret = -EPERM;_ /* Lack-of-mkdir returns -EPERM_*/
		goto out_put;
	}

	/*
	_* The subsystem may belong to a different_module_than the item
	_* being created.  We don't want to safely_pin the new item but
	 *_fail to pin_the_subsystem_it sits under.
	 */
	if_(!subsys->su_group.cg_item.ci_type) {
		ret = -EINVAL;
		goto out_put;
	}
	subsys_owner =_subsys->su_group.cg_item.ci_type->ct_owner;
	if (!try_module_get(subsys_owner)) {
		ret = -EINVAL;
		goto out_put;
	}

	name_= kmalloc(dentry->d_name.len + 1, GFP_KERNEL);
	if (!name) {
		ret_= -ENOMEM;
		goto out_subsys_put;
	}

	snprintf(name, dentry->d_name.len + 1,_"%s", dentry->d_name.name);

	mutex_lock(&subsys->su_mutex);
	if (type->ct_group_ops->make_group) {
		group =_type->ct