forked from mirrors/linux
		
	cgroup: Homogenize cgroup_get_from_id() return value
Cgroup id is user provided datum hence extend its return domain to include possible error reason (similar to cgroup_get_from_fd()). This change also fixes commitd4ccaf58a8("bpf: Introduce cgroup iter") that would use NULL instead of proper error handling ind4ccaf58a8("bpf: Introduce cgroup iter"). Additionally, neither of: fc_appid_store, bpf_iter_attach_cgroup, mem_cgroup_get_from_ino (callers of cgroup_get_from_fd) is built without CONFIG_CGROUPS (depends via CONFIG_BLK_CGROUP, direct, transitive CONFIG_MEMCG respectively) transitive, so drop the singular definition not needed with !CONFIG_CGROUPS. Fixes:d4ccaf58a8("bpf: Introduce cgroup iter") Signed-off-by: Michal Koutný <mkoutny@suse.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
		
							parent
							
								
									4534dee941
								
							
						
					
					
						commit
						fa7e439cf9
					
				
					 4 changed files with 6 additions and 11 deletions
				
			
		| 
						 | 
					@ -19,8 +19,8 @@ int blkcg_set_fc_appid(char *app_id, u64 cgrp_id, size_t app_id_len)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cgrp = cgroup_get_from_id(cgrp_id);
 | 
						cgrp = cgroup_get_from_id(cgrp_id);
 | 
				
			||||||
	if (!cgrp)
 | 
						if (IS_ERR(cgrp))
 | 
				
			||||||
		return -ENOENT;
 | 
							return PTR_ERR(cgrp);
 | 
				
			||||||
	css = cgroup_get_e_css(cgrp, &io_cgrp_subsys);
 | 
						css = cgroup_get_e_css(cgrp, &io_cgrp_subsys);
 | 
				
			||||||
	if (!css) {
 | 
						if (!css) {
 | 
				
			||||||
		ret = -ENOENT;
 | 
							ret = -ENOENT;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -750,11 +750,6 @@ static inline bool task_under_cgroup_hierarchy(struct task_struct *task,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen)
 | 
					static inline void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen)
 | 
				
			||||||
{}
 | 
					{}
 | 
				
			||||||
 | 
					 | 
				
			||||||
static inline struct cgroup *cgroup_get_from_id(u64 id)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return NULL;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#endif /* !CONFIG_CGROUPS */
 | 
					#endif /* !CONFIG_CGROUPS */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_CGROUPS
 | 
					#ifdef CONFIG_CGROUPS
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6005,7 +6005,7 @@ void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen)
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * cgroup_get_from_id : get the cgroup associated with cgroup id
 | 
					 * cgroup_get_from_id : get the cgroup associated with cgroup id
 | 
				
			||||||
 * @id: cgroup id
 | 
					 * @id: cgroup id
 | 
				
			||||||
 * On success return the cgrp, on failure return NULL
 | 
					 * On success return the cgrp or ERR_PTR on failure
 | 
				
			||||||
 * Only cgroups within current task's cgroup NS are valid.
 | 
					 * Only cgroups within current task's cgroup NS are valid.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct cgroup *cgroup_get_from_id(u64 id)
 | 
					struct cgroup *cgroup_get_from_id(u64 id)
 | 
				
			||||||
| 
						 | 
					@ -6037,7 +6037,7 @@ struct cgroup *cgroup_get_from_id(u64 id)
 | 
				
			||||||
		cgrp = NULL;
 | 
							cgrp = NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
out:
 | 
					out:
 | 
				
			||||||
	return cgrp;
 | 
						return cgrp ?: ERR_PTR(-ENOENT);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL_GPL(cgroup_get_from_id);
 | 
					EXPORT_SYMBOL_GPL(cgroup_get_from_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5110,8 +5110,8 @@ struct mem_cgroup *mem_cgroup_get_from_ino(unsigned long ino)
 | 
				
			||||||
	struct mem_cgroup *memcg;
 | 
						struct mem_cgroup *memcg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cgrp = cgroup_get_from_id(ino);
 | 
						cgrp = cgroup_get_from_id(ino);
 | 
				
			||||||
	if (!cgrp)
 | 
						if (IS_ERR(cgrp))
 | 
				
			||||||
		return ERR_PTR(-ENOENT);
 | 
							return PTR_ERR(cgrp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	css = cgroup_get_e_css(cgrp, &memory_cgrp_subsys);
 | 
						css = cgroup_get_e_css(cgrp, &memory_cgrp_subsys);
 | 
				
			||||||
	if (css)
 | 
						if (css)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue